Get the status code from the exception.

@param \Exception $exception

@return int
172355
protected function getStatusCode(Exception $exception)
    {
        if ($exception instanceof ValidationException) {
            return $exception->status;
        }

        return $this->getExceptionStatusCode($exception);
    }
882355
protected function getClass(\Exception $exception)
    {
        $message = '';

        if (($previous = $exception->getPrevious())) {
            $message = $this->getClass($previous) . ' < '; // Recurse
        }

        // Let the exception lie about its class: to support marshalling exceptions
        if (method_exists($exception, 'getClass')) {
            $message .= $exception->getClass();
        } else {
            $message .= get_class($exception);
        }

        return $message;
    }
926449
protected function getStatusCode(Exception $exception): int
    {
        if ($exception instanceof ApiException) {
            return $exception->getStatusCode();
        }

        if ($exception instanceof HttpExceptionInterface && method_exists($exception, 'getStatusCode')) {
            return $exception->getStatusCode();
        }

        return 500;
    }
467704
protected function getLevel( Exception $exception )
	{
		foreach ( array_get( $this->getConfig(), 'levels', [] ) as $class => $level )
			if ( $exception instanceof $class )
				return $level;

		return 'error';
	}
1071082
private function serializeException(\Exception $exception)
    {
        $result = [
            'code'    => $exception->getCode(),
            'message' => $exception->getMessage(),
            'file'    => $exception->getFile(),
            'line'    => $exception->getLine(),
            'trace'   => $exception->getTraceAsString(),
        ];

        if ($exception->getPrevious() !== null) {
            $result['previous'] = $this->serializeException($exception->getPrevious());
        }

        return $result;
    }
329998
public function display(Exception $exception)
	{
		$status = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : 500;

		return new Response(file_get_contents(__DIR__.'/resources/plain.html'), $status);
	}
712051
public function withException(\Exception $exception)
    {
        assert(!is_null($exception), 'Exception must not be null');

        return $this->withDetail('error', $exception->getMessage());
    }
336011
final public static function getBaseException(\Exception $exception)
    {
        while ($exception->getPrevious() !== null) {
            $exception = $exception->getPrevious();
        }

        return $exception;
    }
627942
public function getStatus()
    {
        if (isset($this->_statuses[(int) $this->status])) {
            return $this->_statuses[(int) $this->status];
        }
        throw new \Exception('Status "' . $this->status . '" not found for Page with id ' . $this->id . '.');
    }
47253
public function display(Exception $exception)
	{
		$status = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : 500;

		return new Response($this->whoops->handleException($exception), $status);
	}
1206785
public static function onException( $exception )
    {
        $_trace = $exception->getTrace();
        $_traceText = static::_cleanTrace( $_trace, 3 );

        if ( E_NOTICE == $exception->getCode() )
        {
            return false;
        }

        static::$_error = array(
            'code'       => $exception->getCode(),
            'type'       => '',
            'message'    => $exception->getMessage(),
            'file'       => $exception->getFile(),
            'line'       => $exception->getLine(),
            'trace'      => $_traceText,
            'traces'     => $exception->getTrace(),
            'source'     => static::_getCodeLines( $exception->getFile(), $exception->getLine(), static::$_sourceLines ),
            'start_line' => static::$_startLine,
        );

        Log::error( static::$_error['message'] . ' (' . static::$_error['code'] . ')' );

        return static::renderError();
    }
103517
protected function getTransformed( Exception $exception )
	{
		foreach ( $this->make( array_get( $this->getConfig(), 'transformers', [] ) ) as $transformer )
		{
			var_dump( $transformer );
			$exception = $transformer->transform( $exception );
		}

		return $exception;
	}
1043083
protected function getErrorMessage(Exception $exception)
    {
        $defaultMessage =  __('Unexpected error. Please contact administrator');
        if (DEBUG_MODE) {
            $defaultMessage = $exception->getMessage();
        }
        return ($exception instanceof common_exception_UserReadableException) ? $exception->getUserMessage() :  $defaultMessage;
    }
1207570
protected function handleException(\Exception $exception)
    {
        $this->response->setStatus(500);
        // may be we want also an exceptionHandler e.g. to notify somebody, ...
        $this->addFlashMessage(
            $exception->getMessage(),
            get_class($exception),
            Message::SEVERITY_ERROR,
            [],
            $exception->getCode()
        );
    }
1290047
public function setException(Exception $exception)
    {
        $this->exception = $exception;
        return $this->raiseStatus(self::Status_Exception);
    }
598675
protected function getExceptionCode()
    {
        $exception = $this->getException();

        if ($exception instanceof HttpException) {
            return $exception->statusCode;
        }

        return $exception->getCode();
    }
290322
public function exceptionHandler($exception)
  {
    if (!\is_null($this->getResponse())) {
      # Run the Error Controller
      $response = $this->runErrorController('',500);

      # Set the error response
      $this->setResponse($response);
    } else {
      # Set HTTP Response Code - we dont even have a response object yet ..
      \http_response_code(500);

    }

    # Log the exception
    $this->getLogger()
         ->critical(
            $exception->getMessage().' in file '.$exception->getFile().' on line '.$exception->getLine(),
            $exception->getTrace()
          );

    return null;
  }