UnauthorizedHttpException
API reference › yii › web › UnauthorizedHttpException
UnauthorizedHttpException represents an “Unauthorized” HTTP exception with status code 401.
Use this exception to indicate that a client needs to authenticate via WWW-Authenticate header to perform the requested action.
If the client is already authenticated and is simply not allowed to
perform the action, consider using a 403 ForbiddenHttpException
or 404 NotFoundHttpException instead.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$statusCode | int | HTTP status code, such as 403, 404, 500, etc. Default: null. | HttpException |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Constructor. | UnauthorizedHttpException |
getName() | HttpException |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(string|null $message = null, int $code = 0, Throwable|null $previous = null)Constructor.
Parameters
| Parameter | Type | Description |
|---|---|---|
$message | string| | Error message |
$code | int | Error code |
$previous | Throwable| | The previous exception used for the exception chaining. |