You should be able to do st like this
} catch (Exception $e) {
if ( 'Secured pdf file are currently not supported.' === $e->getMessage() ) {
// do what you want
} else {
throw $e;
}
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I have a problem with a PDF parser.
I have an error with secured PDF files and I want to catch the exception.
$parser = new \Smalot\PdfParser\Parser();
foreach ($documents as $document) {
try {
$pdfFile = $parser->parseFile(storage_path('app/'.$document->fichier));
} catch (Exception $e) {
//
}
}
But when I run this code, it generates an exception which is not catched and the program stops.
Secured pdf file are currently not supported.
What's wrong with my try ... catch ?
Is there another way to catch an exception with Laravel ?
Thanks for your help.
Vincent
Please or to participate in this conversation.