Used by {@see RequestHandler::httpError}

@param int $statusCode
@param HTTPRequest $request
@throws HTTPResponse_Exception
769713
public function onBeforeHTTPError($statusCode, $request)
    {
        if (Director::is_ajax()) {
            return;
        }
        $response = ErrorPage::response_for($statusCode);
        if ($response) {
            throw new HTTPResponse_Exception($response, $statusCode);
        }
    }
1347159
protected function _respondToError($errorMessage, $httpCode) {
        $this->_setHttpStatusCode($httpCode);
        $this->view->result = array(
            'success' => false,
            'errorMessage' => $errorMessage
        );
    }
1156530
public function onBeforeHTTPError($code, $request)
    {

        $errorPage = ErrorPage::get()->filter(array(
                'ErrorCode' => $code,
                'SiteID' => Multisites::inst()->getCurrentSiteId()
            ))->first();
        if ($errorPage) {
            Requirements::clear();
            Requirements::clear_combined_files();
            $response = ModelAsController::controller_for($errorPage)->handleRequest($request);
            throw new HTTPResponse_Exception($response, $code);
        }
    }
1176861
public function response($statusCode = null)
        {
            $response = $this->factory(__NAMESPACE__ . '\Response');

            if (is_numeric($statusCode)) {
                $response->status($statusCode);
            }

            return $response;
        }
968572
public function hasStatusCode($statusCode)
    {
        try {
            $statusCode = $this->filterStatusCode($statusCode);
        } catch (InvalidArgumentException $e) {
            return false;
        }

        return isset($this->httpStatus[$statusCode]);
    }
741260
public static function send_status($code) {
	if (!isset(static::$status_messages[$code])) {
		$code = self::STATUS_INTERNAL_SERVER_ERROR;
	}
	
	http_response_code($code);
}
175420
public static function isError(int $statusCode): bool
    {
        return ($statusCode >= HttpStatus::CLIENT_ERROR) && ($statusCode < HttpStatus::SERVER_ERROR_END);
    }
1188419
protected function validateStatusCode($statusCode) : void
	{
		if (! \is_int($statusCode))
		{
			throw new \InvalidArgumentException('HTTP status-code must be an integer');
		}
		else if (! ($statusCode >= 100 && $statusCode <= 599))
		{
			throw new \InvalidArgumentException(\sprintf('The given status-code "%d" is not valid', $statusCode));
		}
	}
802759
public function respondExceptionError($status, $message, $status_code, $payload)
    {
        $responseData = $this->getResponseStructure($status, $payload, $message);
        $response = new JsonResponse($responseData, $status_code, $this->getHeaders());

        return $response;
    }
636957
public function sendHeaderStatus($statusCode, $reasonPhrase, $protocol = '1.1')
    {
        $this->statusCode = $statusCode;
        $this->reasonPhrase = empty($reasonPhrase) ? error_code_string($statusCode) : $reasonPhrase;

        @header('HTTP/' . $protocol . ' ' . $statusCode . ' ' . $reasonPhrase, true);

        return $this;
    }
1324326
private function createThrowableJsonApiResponse(
        Throwable $throwable,
        string $content,
        int $status
    ): ThrowableResponseInterface {
        return new class ($throwable, $content, $status) extends JsonApiResponse implements ThrowableResponseInterface
        {
            /**
             * @var Throwable
             */
            private $throwable;

            /**
             * @param Throwable $throwable
             * @param string    $content
             * @param int       $status
             */
            public function __construct(Throwable $throwable, string $content, int $status)
            {
                parent::__construct($content, $status);
                $this->throwable = $throwable;
            }

            /**
             * @return Throwable
             */
            public function getThrowable(): Throwable
            {
                return $this->throwable;
            }
        };
    }
390193
public function errors(int $statusCode, string $message, $errors = null): void
    {
        $this->setStatusCode($statusCode);
        $this->setMessage($message);
        $this->setErrors($errors);

        throw new ApiException($this);
    }
128203
public static function assertJsonResponse(Response $response, $statusCode = 200)
    {
        \PHPUnit\Framework\Assert::assertEquals(
            $statusCode,
            $response->getStatusCode(),
            $response->getContent()
        );
        \PHPUnit\Framework\Assert::assertTrue(
            $response->headers->contains('Content-Type', 'application/json'),
            $response->headers
        );
    }
692845
protected function responseError($body, $httpCode)
    {
        return $this->parseResponse($body) ?: $this->jsonError($body, $httpCode);
    }
1207929
public function setRedirectUri(UriInterface $uri, int $statusCode = 303): void
    {
        $this->redirectUri = $uri;
        $this->statusCode = $statusCode;
        // TODO: This can be removed after the full changes are done for next major.
        $this->headers->set('Location', (string)$uri, true);
        $this->setStatusCode($statusCode);
    }
1029473
public function httpError($code)
    {
        switch ($code)
        {
            case 400:
                throw new Eresus_HTTP_Exception_BadRequest;
            case 401:
                throw new Eresus_HTTP_Exception_Unauthorized;
            case 402:
                throw new Eresus_HTTP_Exception_PaymentRequired;
            case 403:
                throw new Eresus_HTTP_Exception_Forbidden;
            case 404:
                throw new Eresus_HTTP_Exception_NotFound;
            default:
                throw new Eresus_HTTP_Exception('', $code);
        }
    }
789551
private function getHttpStatusCode($statusCode)
    {
        if ($statusCode >= 100 && $statusCode < 600) {
            return $statusCode;
        } elseif (
                FrontControllerException::BAD_REQUEST === $statusCode
                || FrontControllerException::INTERNAL_ERROR === $statusCode
                || FrontControllerException::NOT_FOUND === $statusCode
        ) {
            return $statusCode - FrontControllerException::UNKNOWN_ERROR;
        }

        return 500;
    }