From f44ada017eac4f607ffeb1caca96a2347d48f38f Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Tue, 3 Dec 2024 13:01:10 +0100 Subject: [PATCH] Some more exceptions (#745) --- src/Smalot/PdfParser/Document.php | 5 +++-- .../Exception/InvalidDictionaryObjectException.php | 12 ++++++++++++ .../PdfParser/Exception/MissingCatalogException.php | 12 ++++++++++++ src/Smalot/PdfParser/PDFObject.php | 5 +++-- 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 src/Smalot/PdfParser/Exception/InvalidDictionaryObjectException.php create mode 100644 src/Smalot/PdfParser/Exception/MissingCatalogException.php diff --git a/src/Smalot/PdfParser/Document.php b/src/Smalot/PdfParser/Document.php index 964592e4..a44b133a 100644 --- a/src/Smalot/PdfParser/Document.php +++ b/src/Smalot/PdfParser/Document.php @@ -33,6 +33,7 @@ namespace Smalot\PdfParser; use Smalot\PdfParser\Encoding\PDFDocEncoding; +use Smalot\PdfParser\Exception\MissingCatalogException; /** * Technical references : @@ -379,7 +380,7 @@ public function getFirstFont(): ?Font /** * @return Page[] * - * @throws \Exception + * @throws MissingCatalogException */ public function getPages() { @@ -415,7 +416,7 @@ public function getPages() return array_values($pages); } - throw new \Exception('Missing catalog.'); + throw new MissingCatalogException('Missing catalog.'); } public function getText(?int $pageLimit = null): string diff --git a/src/Smalot/PdfParser/Exception/InvalidDictionaryObjectException.php b/src/Smalot/PdfParser/Exception/InvalidDictionaryObjectException.php new file mode 100644 index 00000000..745bd574 --- /dev/null +++ b/src/Smalot/PdfParser/Exception/InvalidDictionaryObjectException.php @@ -0,0 +1,12 @@ +