PHPDaemon\Core\Daemon::uncaughtExceptionHandler PHP Method

uncaughtExceptionHandler() public static method

Uncaught exception handler
public static uncaughtExceptionHandler ( Exception $e ) : void
$e Exception
return void
    public static function uncaughtExceptionHandler(\Exception $e)
    {
        if (Daemon::$context !== null) {
            if (Daemon::$context->handleException($e)) {
                return;
            }
        }
        $msg = $e->getMessage();
        Daemon::log('Uncaught ' . get_class($e) . ' (' . $e->getCode() . ')' . (mb_orig_strlen($msg) ? ': ' . $msg : '') . ".\n" . $e->getTraceAsString());
        if (Daemon::$context instanceof \PHPDaemon\Request\Generic) {
            Daemon::$context->out('<b>Uncaught ' . get_class($e) . ' (' . $e->getCode() . ')</b>' . (mb_orig_strlen($msg) ? ': ' . $msg : '') . '.<br />');
        }
    }

Usage Example

Beispiel #1
0
 /**
  * Called when timer is triggered
  * @return void
  */
 public function eventCall()
 {
     try {
         //Daemon::log('cb - '.Debug::zdump($this->cb));
         call_user_func($this->cb, $this);
     } catch (\Exception $e) {
         Daemon::uncaughtExceptionHandler($e);
     }
 }
All Usage Examples Of PHPDaemon\Core\Daemon::uncaughtExceptionHandler