HttpException
extends Exception
in package
Class HttpException.
Custom exception class for HTTP-related errors, extending the base Exception class. Provides additional functionality to handle HTTP status codes and custom error codes.
Table of Contents
- $errorCode : null|int
- $statusCode : int
- __construct() : mixed
- Constructor for the HttpException class.
- getErrorCode() : null|int
- Get the custom error code associated with the exception.
- getStatusCode() : int
- Get the HTTP status code associated with the exception.
Properties
$errorCode
protected
null|int
$errorCode
Custom error code associated with the exception.
$statusCode
protected
int
$statusCode
HTTP status code associated with the exception.
Methods
__construct()
Constructor for the HttpException class.
public
__construct(string $message[, int $statusCode = 500 ][, null|int $errorCode = null ][, null|Throwable $previous = null ]) : mixed
Parameters
- $message : string
-
The exception message.
- $statusCode : int = 500
-
HTTP status code (default is 500).
- $errorCode : null|int = null
-
Custom error code for application-specific error handling (optional).
- $previous : null|Throwable = null
-
Previous throwable used for exception chaining (optional).
Return values
mixed —getErrorCode()
Get the custom error code associated with the exception.
public
getErrorCode() : null|int
Return values
null|int —The custom error code, or null if not set.
getStatusCode()
Get the HTTP status code associated with the exception.
public
getStatusCode() : int
Return values
int —The HTTP status code.