diff options
Diffstat (limited to 'lib/Service/Exceptions/ServiceException.php')
-rw-r--r-- | lib/Service/Exceptions/ServiceException.php | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/Service/Exceptions/ServiceException.php b/lib/Service/Exceptions/ServiceException.php index c5ddddbd9..69b963ab6 100644 --- a/lib/Service/Exceptions/ServiceException.php +++ b/lib/Service/Exceptions/ServiceException.php @@ -13,16 +13,35 @@ namespace OCA\News\Service\Exceptions; -class ServiceException extends \Exception +use Exception; +use OCP\AppFramework\Db\IMapperException; + +/** + * Class ServiceException + * + * @package OCA\News\Service\Exceptions + */ +abstract class ServiceException extends Exception { /** * Constructor * * @param string $msg the error message + * @param int $code + * @param Exception|null $previous */ - public function __construct(string $msg) + final public function __construct(string $msg, int $code = 0, ?Exception $previous = null) { - parent::__construct($msg); + parent::__construct($msg, $code, $previous); } + + /** + * Create exception from Mapper exception. + * + * @param IMapperException|Exception $exception Existing exception + * + * @return static + */ + abstract public static function from(IMapperException $exception): ServiceException; } |