Get the exception status code.

@param \Exception $exception
@param int        $defaultStatusCode

@return int
321413
protected function getExceptionStatusCode(Exception $exception, $defaultStatusCode = null): int
    {
        if (null === $defaultStatusCode) {
            $defaultStatusCode = 500;
        }

        return ($exception instanceof HttpExceptionInterface) ? $exception->getStatusCode() : $defaultStatusCode;
    }
225324
private function getErrorPageResponse(\Exception $exception, $statusCode)
    {
        $parameter = $this->application->getContainer()->getParameter('error.default');
        if ($this->application->getContainer()->hasParameter('error.'.$statusCode)) {
            $parameter = $this->application->getContainer()->getParameter('error.'.$statusCode);
        }

        $view = $this->getErrorTemplate($parameter);

        return new Response($this->renderer->partial($view, ['error' => $exception]), $statusCode);
    }
399013
protected function getThrottleCacheKey(Exception $exception)
    {

        // if we haven't already set the cache key lets set it
        if ($this->throttleCacheKey == null) {
            // make up the cache key from a prefix, exception class, exception message, and exception code
            // with all special characters removed
            $this->throttleCacheKey = preg_replace(
                "/[^A-Za-z0-9]/",
                '',
                'laravelEmailException'.get_class($exception).$exception->getMessage().$exception->getCode()
            );
        }

        // return the cache key
        return $this->throttleCacheKey;
    }
137435
public static function exception_handler(\Exception $exception) {
		global $CFG, $USR;
		$errcode = $exception->getCode();
		$errmsg = $exception->getMessage();
		$errcodelabel = ($exception instanceof \pdyn\base\Exception)
			? $exception->get_string_from_code($errcode)
			: static::getinternalerrorlabel($errcode);
		if (\pdyn\base\Utils::is_cli_env() === true) {
			echo 'APP ERROR: '.$errcodelabel.': '.$errmsg."\n";
		} else {
			// Atlas exceptions' error codes are HTTP status codes, so send one.
			if (($exception instanceof \pdyn\base\Exception) && !empty($errcode) && !headers_sent()) {
				\pdyn\httputils\Utils::send_status_code($errcode, '', false);
			} else {
				\pdyn\httputils\Utils::send_status_code(500, '', false);
			}
			$LOG = new \pdyn\log\Logger($CFG->log_general);
			$LOG->error($errcodelabel.': '.$exception);
			if (isset($_GET['ajax'])) {
				header('Content-type: application/json');
				echo json_encode(['result' => 'fail', 'msg' => $errcodelabel.': '.$errmsg]);
			} else {
				$debugmode = (!empty($CFG) && (bool)$CFG->get('core', 'debugmode', false) === true) ? true : false;
				$isadmin = (!empty($USR) && $USR->is_admin === true) ? true : false;
				$backtrace = ($isadmin === true || $debugmode === true)	? static::format_backtrace($exception->getTrace()) : null;
				static::write_error_html($errcodelabel, $errmsg, $errcode, $backtrace);
			}
		}
		die();
	}
275337
public function sendException(\Exception $exception)
  {
    $this->setStatusCode($exception->getCode(), $exception->getMessage());

    $this->setJsonContent($this);

    return parent::send();
  }
36367
protected function toPrettyErrorResponse( $exception ) {
		$method = RunInterface::EXCEPTION_HANDLER;
		ob_start();
		$this->whoops->$method( $exception );
		$response = ob_get_clean();
		return Response::output( $response )->withStatus( 500 );
	}
868732
protected function getExceptionStatusCode(Exception $exception, $defaultStatusCode = 500)
    {
        if ($exception instanceof NodesException) {
            return [
                $exception->getStatusCode(),
                $exception->getStatusMessage(),
            ];
        } elseif ($exception instanceof HttpExceptionInterface) {
            return $exception->getStatusCode();
        } else {
            return $defaultStatusCode;
        }
    }
795134
protected function createStatusFromException()
    {
        $e      = $this->detail;
        $status = $e->getCode();

        if (empty($status)
            || ($status < 100)
            || ($status > 599)
        ) {
            return 500;
        }

        return $status;
    }
396122
public function return404($notifier = false, \Exception $exception = null)
    {
    	if (!defined('ERROR_404'))
    	{
    	    define('ERROR_404', 'Y');
    	}

        \CHTTP::SetStatus('404 Not Found');

        if ($exception !== false)
        {
            if ($notifier === false)
            {
                $this->exceptionNotifier = false;
            }

            if ($exception instanceof \Exception)
            {
                throw $exception;
            }
            else
            {
                throw new \Exception('Page not found');
            }
        }
    }
436119
protected function echoExceptionWeb($exception)
    {
        $statusCode = ($exception instanceof WithHttpStatusInterface) ? $exception->getStatusCode() : 500;
        $statusMessage = ResponseInformationHelper::getStatusMessageByCode($statusCode);
        $referenceCode = ($exception instanceof WithReferenceCodeInterface) ? $exception->getReferenceCode() : null;
        if (!headers_sent()) {
            header(sprintf('HTTP/1.1 %s %s', $statusCode, $statusMessage));
        }

        try {
            if (isset($this->renderingOptions['templatePathAndFilename'])) {
                try {
                    echo $this->buildView($exception, $this->renderingOptions)->render();
                } catch (\Throwable $throwable) {
                    $this->renderStatically($statusCode, $throwable);
                }
            } else {
                echo $this->renderStatically($statusCode, $referenceCode);
            }
        } catch (\Exception $innerException) {
            $message = $this->throwableStorage->logThrowable($innerException);
            $this->logger->critical($message);
        }
    }
593428
public function exception($exception = null)
    {
        if (!func_num_args()) {
            return $this->_exception;
        }
        $this->_exception = $exception;
        return $this;
    }
58375
public function setDefaultException(\Exception $defaultException = null)
    {
        if (!$defaultException instanceof Exception) {
            @trigger_error('Clients may only throw exceptions of type '.Exception::class.'. Setting an exception of class '.get_class($defaultException).' will not be possible anymore in the future', E_USER_DEPRECATED);
        }
        $this->defaultException = $defaultException;
    }
942685
protected function getDistalCause(\Exception $exception)
    {
        if (($previous = $exception->getPrevious())) {
            return $this->getDistalCause($previous);
        }
        return $exception;
    }
1290047
public function setException(Exception $exception)
    {
        $this->exception = $exception;
        return $this->raiseStatus(self::Status_Exception);
    }
95623
public function getStatusCode()
    {
        $headers = $this->getHeaders();
        if ($headers->has('http-code')) {
            // take into account possible 'follow location'
            $statusCodeHeaders = $headers->get('http-code', null, false);
            return empty($statusCodeHeaders) ? null : end($statusCodeHeaders);
        }
        throw new Exception('Unable to get status code: referred header information is missing.');
    }
589842
protected function getCode(\Exception $exception)
    {
        return $exception instanceof \ErrorException ?
            $this->getHumanErrorCode($exception->getSeverity()) :
            $exception->getCode()
        ;
    }
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;
    }