diff --git a/src/PhpWord/Exceptions/InvalidObjectException.php b/src/PhpWord/Exceptions/InvalidObjectException.php new file mode 100644 index 00000000..4d10d71a --- /dev/null +++ b/src/PhpWord/Exceptions/InvalidObjectException.php @@ -0,0 +1,34 @@ +_elementCollection[] = $object; return $object; + } else { + throw new InvalidObjectException; } - throw new Exception('Source does not exist or unsupported object type.'); } /** @@ -270,7 +272,7 @@ class Section * @param string $src * @param mixed $style * @return \PhpOffice\PhpWord\Section\Image - * @throws \PhpOffice\PhpWord\Exceptions\Exception + * @throws \PhpOffice\PhpWord\Exceptions\InvalidImageException */ public function addImage($src, $style = null) { @@ -281,7 +283,7 @@ class Section $this->_elementCollection[] = $image; return $image; } else { - throw new Exception('Source does not exist or unsupported image type.'); + throw new InvalidImageException; } } diff --git a/src/PhpWord/Section/Footer.php b/src/PhpWord/Section/Footer.php index b33211a8..efd47892 100755 --- a/src/PhpWord/Section/Footer.php +++ b/src/PhpWord/Section/Footer.php @@ -25,7 +25,7 @@ namespace PhpOffice\PhpWord\Section; -use PhpOffice\PhpWord\Exceptions\Exception; +use PhpOffice\PhpWord\Exceptions\InvalidImageException; use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\Section\Footer\PreserveText; use PhpOffice\PhpWord\Shared\String; @@ -140,7 +140,7 @@ class Footer $this->_elementCollection[] = $image; return $image; } else { - throw new Exception('Source does not exist or unsupported image type.'); + throw new InvalidImageException; } } diff --git a/src/PhpWord/Section/Header.php b/src/PhpWord/Section/Header.php index 8faf135e..d284dcf8 100755 --- a/src/PhpWord/Section/Header.php +++ b/src/PhpWord/Section/Header.php @@ -25,7 +25,7 @@ namespace PhpOffice\PhpWord\Section; -use PhpOffice\PhpWord\Exceptions\Exception; +use PhpOffice\PhpWord\Exceptions\InvalidImageException; use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\Section\Footer\PreserveText; use PhpOffice\PhpWord\Shared\String; @@ -169,7 +169,7 @@ class Header $this->_elementCollection[] = $image; return $image; } else { - throw new Exception('Source does not exist or unsupported image type.'); + throw new InvalidImageException; } } @@ -219,7 +219,7 @@ class Header $this->_elementCollection[] = $image; return $image; } else { - throw new Exception('Src does not exist or invalid image type.'); + throw new InvalidImageException; } } diff --git a/src/PhpWord/Section/Table/Cell.php b/src/PhpWord/Section/Table/Cell.php index 80e66493..06deafa5 100755 --- a/src/PhpWord/Section/Table/Cell.php +++ b/src/PhpWord/Section/Table/Cell.php @@ -26,6 +26,8 @@ namespace PhpOffice\PhpWord\Section\Table; use PhpOffice\PhpWord\Exceptions\Exception; +use PhpOffice\PhpWord\Exceptions\InvalidObjectException; +use PhpOffice\PhpWord\Exceptions\InvalidImageException; use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\Section\Footer\PreserveText; use PhpOffice\PhpWord\Section\Image; @@ -212,7 +214,7 @@ class Cell $this->_elementCollection[] = $image; return $image; } else { - throw new Exception('Source does not exist or unsupported image type.'); + throw new InvalidImageException; } } @@ -265,7 +267,7 @@ class Cell $this->_elementCollection[] = $object; return $object; } else { - throw new Exception('Source does not exist or unsupported object type.'); + throw new InvalidObjectException; } } diff --git a/src/PhpWord/Section/TextRun.php b/src/PhpWord/Section/TextRun.php index 77b203eb..55236cb9 100755 --- a/src/PhpWord/Section/TextRun.php +++ b/src/PhpWord/Section/TextRun.php @@ -25,7 +25,7 @@ namespace PhpOffice\PhpWord\Section; -use PhpOffice\PhpWord\Exceptions\Exception; +use PhpOffice\PhpWord\Exceptions\InvalidImageException; use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Style\Paragraph; @@ -131,7 +131,7 @@ class TextRun $this->_elementCollection[] = $image; return $image; } else { - throw new Exception('Source does not exist or unsupported image type.'); + throw new InvalidImageException; } }