Example #1
0
 /**
  * @param \Exception $e
  *
  * @throws \Exception
  */
 public function error(\Exception $e)
 {
     if ($this->beep_on_error === true) {
         \Commando\Util\Terminal::beep();
     }
     if ($this->trap_errors !== true) {
         throw $e;
     }
     $color = new \Colors\Color();
     $error = sprintf('ERROR: %s ', $e->getMessage());
     echo $color($error)->bg('red')->bold()->white() . PHP_EOL;
     exit(1);
 }
Example #2
0
 /**
  * @param callable $callback
  */
 public static function execute(\Closure $callback)
 {
     if (static::$set_error_handler) {
         static::_setErrorHandler();
     }
     try {
         $callback();
     } catch (\Exception $e) {
         if (static::$beep_on_error) {
             Terminal::beep();
         }
         $msg = sprintf("PHP Fatal error:  Uncaught exception '%s' with message '%s' in %s:%s", get_class($e), $e->getMessage(), $e->getFile(), $e->getLine());
         static::msgError($msg);
         static::errorLn('Stack trace:');
         static::errorLn(static::text($e->getTraceAsString())->bold());
         static::errorLn(sprintf(static::text('  thrown in %s on line %s')->bold(), $e->getFile(), $e->getLine()));
         exit(1);
     }
     exit(0);
 }