Airbrake\Client::notifyOnError PHP Method

notifyOnError() public method

Notify on an error message.
public notifyOnError ( string $message, array $backtrace = null, null $extraParams = null ) : string
$message string
$backtrace array
$extraParams null
return string
    public function notifyOnError($message, array $backtrace = null, $extraParams = null)
    {
        if (!$backtrace) {
            $backtrace = debug_backtrace();
            if (count($backtrace) > 1) {
                array_shift($backtrace);
            }
        }
        $notice = new Notice();
        $notice->load(array('errorClass' => 'PHP::Error', 'backtrace' => $backtrace, 'errorMessage' => $message, 'extraParameters' => $extraParams));
        return $this->notify($notice);
    }

Usage Example

 /**
  * Handles the PHP shutdown event.
  *
  * This event exists almost solely to provide a means to catch and log errors that might have been
  * otherwise lost when PHP decided to die unexpectedly.
  */
 public function onShutdown()
 {
     // Get the last error if there was one, if not, let's get out of here.
     if (!($error = error_get_last())) {
         return;
     }
     $fatal = array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR);
     if (!in_array($error['type'], $fatal)) {
         return;
     }
     $message = '[Shutdown Error]: %s';
     $message = sprintf($message, $error['message']);
     $backtrace = array(array('file' => $error['file'], 'line' => $error['line']));
     $this->client->notifyOnError($message, $backtrace);
     error_log($message . ' in: ' . $error['file'] . ':' . $error['line']);
 }
All Usage Examples Of Airbrake\Client::notifyOnError