Open rgozdzialski opened 8 years ago
Warnings cleaned by "@" are mainly generated by "TCPDF" library. I'm surprised you can't catch warning with a standard try-catch block. You are not supposed to catch warning or notice using try/catch. Are you sure everything is solved when you remove "@" from the API ?
Hm, you are right, it goes deeper. Removing the @ did not resolve the problem. The stack looks like this:
in tcpdf_filters.php line 357
at FatalErrorException->__construct() in HandleExceptions.php line 133
at HandleExceptions->fatalExceptionFromError() in HandleExceptions.php line 118
at HandleExceptions->handleShutdown() in HandleExceptions.php line 0
at gzuncompress() in tcpdf_filters.php line 357
at TCPDF_FILTERS::decodeFilterFlateDecode() in tcpdf_filters.php line 94
at TCPDF_FILTERS::decodeFilter() in tcpdf_parser.php line 781
at TCPDF_PARSER->decodeStream() in tcpdf_parser.php line 702
at TCPDF_PARSER->getIndirectObject() in tcpdf_parser.php line 123
at TCPDF_PARSER->__construct() in Parser.php line 88
at Parser->parseContent() in Parser.php line 74
And the line 357 in tcpdf_filter.php:
public static function decodeFilterFlateDecode($data) {
// initialize string to return
$decoded = @gzuncompress($data); // <= Breaks here
if ($decoded === false) {
self::Error('decodeFilterFlateDecode: invalid code');
}
return $decoded;
}
As you can see, the line is also suppressed, but it's not your doing of course. I think you can close the issue, however I still have no idea how I am supposed to catch this (apparently silenced) error.
Long story short, one of the PDF files I'm trying to parse throws an error - it basically cannot be parsed. Thing is that I cannot catch it with the standard try-catch block, because the
parseFile()
method from your package suppresses any errors thrown while parsing:And the line in the Parser.php file: https://github.com/smalot/pdfparser/blob/master/src/Smalot/PdfParser/Parser.php#L74
I would say remove the @. And I would do it everywhere else you might have used it. What do you think?