src/Handlers/ExceptionHandler.php
private function handleForConsole(Exception $e)
    {
        if ($e instanceof StopException) {
            $output = $e->getMessage();
        }
        else {
            $data = $this->convertException($e);
            $class = get_class($e);
            $file  = $this->stripFile($data['file']);
            $line  = $data['line'];
            $code  = $data['code'];

            // set the error message
            if ($e instanceof HttpException) {
                $message = http_status_text($data['status']) . ' (' . $data['status'] . ')';
                if (!empty($data['message'])) {
                    $message .=  '. ' . $data['message'];
                }
            }
            else if ($e instanceof QueryException) {
                $message = $data['message'] . '; sql: ' . $data['sql'];
            }
            else {
                $message = $data['message'];
            }

            $output = $class . ' in "' . $file . '", line ' . $line . ':' . PHP_EOL . $message . ' (code ' . $code . ')';
        }

        stdio()->error($output);

        $exitCode = $e->getCode();
        if ($exitCode === null) {
            $exitCode = Command::EXIT_FAILURE;
        }

        exit ($exitCode);
    }
private function handleForConsole(Exception $e)
    {
        if ($e instanceof StopException) {
            $output = $e->getMessage();
        }
        else {
            $data = $this->convertException($e);
            $class = get_class($e);
            $file  = $this->stripFile($data['file']);
            $line  = $data['line'];
            $code  = $data['code'];

            // set the error message
            if ($e instanceof HttpException) {
                $message = http_status_text($data['status']) . ' (' . $data['status'] . ')';
                if (!empty($data['message'])) {
                    $message .=  '. ' . $data['message'];
                }
            }
            else if ($e instanceof QueryException) {
                $message = $data['message'] . '; sql: ' . $data['sql'];
            }
            else {
                $message = $data['message'];
            }

            $output = $class . ' in "' . $file . '", line ' . $line . ':' . PHP_EOL . $message . ' (code ' . $code . ')';
        }

        stdio()->error($output);

        $exitCode = $e->getCode();
        if ($exitCode === null) {
            $exitCode = Command::EXIT_FAILURE;
        }

        exit ($exitCode);
    }
private function handleForConsole ( Exception $ e ) { if ( $ e instanceof StopException ) { $ output = $ e -> getMessage ( ) ; } else { $ data = $ this -> convertException ( $ e ) ; $ class = get_class ( $ e ) ; $ file = $ this -> stripFile ( $ data [ 'file' ] ) ; $ line = $ data [ 'line' ] ; $ code = $ data [ 'code' ] ; // set the error message if ( $ e instanceof HttpException ) { $ message = http_status_text ( $ data [ 'status' ] ) . ' (' . $ data [ 'status' ] . ')' ; if ( ! empty ( $ data [ 'message' ] ) ) { $ message .= '. ' . $ data [ 'message' ] ; } } else if ( $ e instanceof QueryException ) { $ message = $ data [ 'message' ] . '; sql: ' . $ data [ 'sql' ] ; } else { $ message = $ data [ 'message' ] ; } $ output = $ class . ' in "' . $ file . '", line ' . $ line . ':' . PHP_EOL . $ message . ' (code ' . $ code . ')' ; } stdio ( ) -> error ( $ output ) ; $ exitCode = $ e -> getCode ( ) ; if ( $ exitCode === null ) { $ exitCode = Command :: EXIT_FAILURE ; } exit ( $ exitCode ) ; }
Write a error message to the console and exit the script.

@param Exception $e
Write a error message to the console and exit the script .