问题描述
当尝试捕获/处理从 PDFParser 引发的异常时,我无法捕获它.我使用了一个简单的try catch语句,概述如下.
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( \Exception $e){
$text = $paper->abstract;
}
引发异常的情况如下.
if (empty($data)) {
throw new \Exception('Object list not found. Possible secured file.');
}
lumen.ERROR:异常:找不到对象列表.可能的受保护文件.在
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堆栈跟踪:
/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 ...')
#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 ...')
#1 /Users/pietrosette/Documents/CS_310/AcademicWordCloud-Backend/app/Http/Controllers/ACMServer.php(198): Smalot\PdfParser\Parser->parseFile('/Users/pietrose...')
推荐答案
您有错别字:
try{
$pdf = $parser->parseFile($filepath);
$text = $pdf->getText();
} catch( \Execption $e){
$text = $paper->abstract;
}
异常"的拼写错误.
这篇关于PHP异常未被捕获,laravel,流明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!