New in Symfony 4.1: Exception improvements
April 24, 2018 • Published by Javier Eguiluz
Warning: This post is about an unsupported Symfony version. Some of this information may be out of date. Read the most recent Symfony Docs.
FlattenException
now unwraps errors
Contributed by
Alexander M. Turek
in #26028.
Symfony wraps errors thrown by the application inside a FatalThrowableError
.
This makes the actual error class to not be displayed in the exception pages,
where you see for example Symfony's FatalThrowableError
instead of PHP's
DivisionByZeroError
when your code tries to divide by 0
.
In Symfony 4.1, FlattenException
now unwraps FatalThrowableError
instances and logs the wrapped error. In consequence, the real error class is
now always displayed in the exception page:
Introduced new exception classes
Contributed by
Sullivan Senechal
and Florent Mata
in #25775
and #26475.
In Symfony 4.1 we've introduced a new ProcessSignaledException
class in the
Process component to properly catch signaled process errors. Also, in the
HttpFoundation component, we've introduced new detailed exception classes for
file upload handling to replace the generic catch-all FileException
:
1 2 3 4 5 6 7
use Symfony\Component\HttpFoundation\File\Exception\CannotWriteFileException;
use Symfony\Component\HttpFoundation\File\Exception\ExtensionFileException;
use Symfony\Component\HttpFoundation\File\Exception\FormSizeFileException;
use Symfony\Component\HttpFoundation\File\Exception\IniSizeFileException;
use Symfony\Component\HttpFoundation\File\Exception\NoFileException;
use Symfony\Component\HttpFoundation\File\Exception\NoTmpDirFileException;
use Symfony\Component\HttpFoundation\File\Exception\PartialFileException;
Moreover, now that PHP 7.1 supports multi catch exception handling, you can
process several exceptions with the same catch()
block:
1 2 3 4 5
try {
// ...
} catch (FormSizeFileException | IniSizeFileException $e) {
// ...
}
Improved the exception page design
Contributed by
Javier Eguiluz
in #26671.
The exception pages have been improved in Symfony 4.1 to display less information
about "vendor code". If some code belongs to the vendor/
folder, we compact
its information to fit in a single line and we no longer display its arguments.
The other code remains the same, which helps you focus more easily on your own
application code:
Help the Symfony project!
As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.