Skip to content

Commit

Permalink
errorexception.xml: remove the extra dot cahr; combed the example code (
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalferov authored Oct 8, 2024
1 parent 44bcc82 commit 2f3c123
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion language/predefined/errorexception.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,30 @@
&reftitle.examples;
<para>
<example xml:id="errorexception.example.error-handler"><!-- {{{ -->
<title>Use <function>set_error_handler</function> to change error messages into ErrorException.</title>
<title>Use <function>set_error_handler</function> to change error messages into ErrorException</title>
<programlisting role="php">
<![CDATA[
<?php
set_error_handler(function (int $errno, string $errstr, string $errfile, int $errline) {
if (!(error_reporting() & $errno)) {
// This error code is not included in error_reporting.
return;
}
if ($errno === E_DEPRECATED || $errno === E_USER_DEPRECATED) {
// Do not throw an Exception for deprecation warnings as new or unexpected
// deprecations would break the application.
return;
}
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
});
// Unserializing broken data triggers a warning which will be turned into an
// ErrorException by the error handler.
unserialize('broken data');
?>
]]>
</programlisting>
Expand Down

0 comments on commit 2f3c123

Please sign in to comment.