3. Error Handling

3.1. Logging PHP errors

Moski2.net provides an error handling mechanism that allows you to intercept all errors thrown by the system. To do this, create a function that receives the error message and register that function as your error handler:

<?php

function myErrorHandler($errorMessage, $errorCode) {
  echo '<h2>My Error Heading</h2>';
  echo '<p>' . $errorMessage . '</p>';
}

$M2->setErrorHandler('myErrorHandler');

?>

Note

The $errorCode parameter currently contains NULL, but the intention is to provide an error code that allows you to perform distinct behaviors depending on the type and severity of the error.

If you don't provide an error handler your site visitors will simply see the plain Moski2.net error page and the script will terminate.