errors
try {
throw new RuntimeException("boom");
} catch (RuntimeException $e) {
echo $e->getMessage();
}
Output:
boom
Catch what you expect
Catch a specific exception class A bare catch hides the bug you were trying to find
Error modes
PHP 8.6 adds structured stream errors
A context can request exceptions instead of warnings
Structured StreamError objects carry a code, wrapper name, and path
Testing it requires an 8.6 runtime
Return from finally
8.6 deprecates return inside finally
It silently discards exceptions and overrides earlier returns
Do not write it in new code
Reporting
Turn error reporting on during development Send logs to a file in production Never display raw errors to a client
Next
Input in 09 web input
Posted