Change exception type
This commit is contained in:
parent
3b020f660c
commit
8aba90ded9
34
src/PhpWord/Exceptions/InvalidObjectException.php
Normal file
34
src/PhpWord/Exceptions/InvalidObjectException.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* PHPWord
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014 PHPWord
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* @category PHPWord
|
||||||
|
* @package PHPWord
|
||||||
|
* @copyright Copyright (c) 2014 PHPWord
|
||||||
|
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
|
||||||
|
* @version 0.8.0
|
||||||
|
*/
|
||||||
|
namespace PhpOffice\PhpWord\Exceptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception used for when an image is not found
|
||||||
|
*/
|
||||||
|
class InvalidObjectException extends Exception
|
||||||
|
{
|
||||||
|
}
|
||||||
@ -25,7 +25,8 @@
|
|||||||
|
|
||||||
namespace PhpOffice\PhpWord;
|
namespace PhpOffice\PhpWord;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Exceptions\Exception;
|
use PhpOffice\PhpWord\Exceptions\InvalidImageException;
|
||||||
|
use PhpOffice\PhpWord\Exceptions\InvalidObjectException;
|
||||||
use PhpOffice\PhpWord\Section\Footer;
|
use PhpOffice\PhpWord\Section\Footer;
|
||||||
use PhpOffice\PhpWord\Section\Image;
|
use PhpOffice\PhpWord\Section\Image;
|
||||||
use PhpOffice\PhpWord\Section\Header;
|
use PhpOffice\PhpWord\Section\Header;
|
||||||
@ -229,7 +230,7 @@ class Section
|
|||||||
* @param string $src
|
* @param string $src
|
||||||
* @param mixed $style
|
* @param mixed $style
|
||||||
* @return \PhpOffice\PhpWord\Section\Object
|
* @return \PhpOffice\PhpWord\Section\Object
|
||||||
* @throws \PhpOffice\PhpWord\Exceptions\Exception
|
* @throws \PhpOffice\PhpWord\Exceptions\InvalidObjectException
|
||||||
*/
|
*/
|
||||||
public function addObject($src, $style = null)
|
public function addObject($src, $style = null)
|
||||||
{
|
{
|
||||||
@ -260,8 +261,9 @@ class Section
|
|||||||
|
|
||||||
$this->_elementCollection[] = $object;
|
$this->_elementCollection[] = $object;
|
||||||
return $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 string $src
|
||||||
* @param mixed $style
|
* @param mixed $style
|
||||||
* @return \PhpOffice\PhpWord\Section\Image
|
* @return \PhpOffice\PhpWord\Section\Image
|
||||||
* @throws \PhpOffice\PhpWord\Exceptions\Exception
|
* @throws \PhpOffice\PhpWord\Exceptions\InvalidImageException
|
||||||
*/
|
*/
|
||||||
public function addImage($src, $style = null)
|
public function addImage($src, $style = null)
|
||||||
{
|
{
|
||||||
@ -281,7 +283,7 @@ class Section
|
|||||||
$this->_elementCollection[] = $image;
|
$this->_elementCollection[] = $image;
|
||||||
return $image;
|
return $image;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Source does not exist or unsupported image type.');
|
throw new InvalidImageException;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
namespace PhpOffice\PhpWord\Section;
|
namespace PhpOffice\PhpWord\Section;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Exceptions\Exception;
|
use PhpOffice\PhpWord\Exceptions\InvalidImageException;
|
||||||
use PhpOffice\PhpWord\Media;
|
use PhpOffice\PhpWord\Media;
|
||||||
use PhpOffice\PhpWord\Section\Footer\PreserveText;
|
use PhpOffice\PhpWord\Section\Footer\PreserveText;
|
||||||
use PhpOffice\PhpWord\Shared\String;
|
use PhpOffice\PhpWord\Shared\String;
|
||||||
@ -140,7 +140,7 @@ class Footer
|
|||||||
$this->_elementCollection[] = $image;
|
$this->_elementCollection[] = $image;
|
||||||
return $image;
|
return $image;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Source does not exist or unsupported image type.');
|
throw new InvalidImageException;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
namespace PhpOffice\PhpWord\Section;
|
namespace PhpOffice\PhpWord\Section;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Exceptions\Exception;
|
use PhpOffice\PhpWord\Exceptions\InvalidImageException;
|
||||||
use PhpOffice\PhpWord\Media;
|
use PhpOffice\PhpWord\Media;
|
||||||
use PhpOffice\PhpWord\Section\Footer\PreserveText;
|
use PhpOffice\PhpWord\Section\Footer\PreserveText;
|
||||||
use PhpOffice\PhpWord\Shared\String;
|
use PhpOffice\PhpWord\Shared\String;
|
||||||
@ -169,7 +169,7 @@ class Header
|
|||||||
$this->_elementCollection[] = $image;
|
$this->_elementCollection[] = $image;
|
||||||
return $image;
|
return $image;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Source does not exist or unsupported image type.');
|
throw new InvalidImageException;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ class Header
|
|||||||
$this->_elementCollection[] = $image;
|
$this->_elementCollection[] = $image;
|
||||||
return $image;
|
return $image;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Src does not exist or invalid image type.');
|
throw new InvalidImageException;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,6 +26,8 @@
|
|||||||
namespace PhpOffice\PhpWord\Section\Table;
|
namespace PhpOffice\PhpWord\Section\Table;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Exceptions\Exception;
|
use PhpOffice\PhpWord\Exceptions\Exception;
|
||||||
|
use PhpOffice\PhpWord\Exceptions\InvalidObjectException;
|
||||||
|
use PhpOffice\PhpWord\Exceptions\InvalidImageException;
|
||||||
use PhpOffice\PhpWord\Media;
|
use PhpOffice\PhpWord\Media;
|
||||||
use PhpOffice\PhpWord\Section\Footer\PreserveText;
|
use PhpOffice\PhpWord\Section\Footer\PreserveText;
|
||||||
use PhpOffice\PhpWord\Section\Image;
|
use PhpOffice\PhpWord\Section\Image;
|
||||||
@ -212,7 +214,7 @@ class Cell
|
|||||||
$this->_elementCollection[] = $image;
|
$this->_elementCollection[] = $image;
|
||||||
return $image;
|
return $image;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Source does not exist or unsupported image type.');
|
throw new InvalidImageException;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +267,7 @@ class Cell
|
|||||||
$this->_elementCollection[] = $object;
|
$this->_elementCollection[] = $object;
|
||||||
return $object;
|
return $object;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Source does not exist or unsupported object type.');
|
throw new InvalidObjectException;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
namespace PhpOffice\PhpWord\Section;
|
namespace PhpOffice\PhpWord\Section;
|
||||||
|
|
||||||
use PhpOffice\PhpWord\Exceptions\Exception;
|
use PhpOffice\PhpWord\Exceptions\InvalidImageException;
|
||||||
use PhpOffice\PhpWord\Media;
|
use PhpOffice\PhpWord\Media;
|
||||||
use PhpOffice\PhpWord\Shared\String;
|
use PhpOffice\PhpWord\Shared\String;
|
||||||
use PhpOffice\PhpWord\Style\Paragraph;
|
use PhpOffice\PhpWord\Style\Paragraph;
|
||||||
@ -131,7 +131,7 @@ class TextRun
|
|||||||
$this->_elementCollection[] = $image;
|
$this->_elementCollection[] = $image;
|
||||||
return $image;
|
return $image;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Source does not exist or unsupported image type.');
|
throw new InvalidImageException;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user