Sunday, April 2, 2017

PHP exception not being caught, laravel, lumen

When attempting to catch/handle an exception thrown from PDFParser, I cannot catch it. I use a simple try catch statement, outlined below.

try{
  $pdf  = $parser->parseFile($filepath);
  $text = $pdf->getText();    
} catch( \Execption $e){
  $text = $paper->abstract;
}

The exception is thrown as follows.

if (empty($data)) {
        throw new \Exception('Object list not found. Possible secured file.');
}

The output is here.

lumen.ERROR: Exception: Object list not found. Possible secured file. in

/Users/pietrosette/Documents/CS_310/AcademicWordCloud-Backend/vendor/smalot/pdfparser/src/Smalot/PdfParser/Parser.php:98 Stack trace:

#0 /Users/pietrosette/Documents/CS_310/AcademicWordCloud-Backend/vendor/smalot/pdfparser/src/Smalot/PdfParser/Parser.php(74): Smalot\PdfParser\Parser->parseContent('%PDF-1.5\r%\xE2\xE3\xCF\xD3\r...')

#1 /Users/pietrosette/Documents/CS_310/AcademicWordCloud-Backend/app/Http/Controllers/ACMServer.php(198): Smalot\PdfParser\Parser->parseFile('/Users/pietrose...')



via Pietro Sette

Advertisement