Skip to content
PHP Ecosystem
Explore

UnauthorizedHttpException

API reference › yii › web › UnauthorizedHttpException

classyii\web\UnauthorizedHttpException
ExtendsHttpException » yii\base\UserException » yii\base\Exception » Exception
Since2.0
Sourceframework/web/UnauthorizedHttpException.php

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.

PropertyTypeDescriptionDefined by
$statusCodeintHTTP status code, such as 403, 404, 500, etc. Default: null.HttpException
MethodDescriptionDefined by
__construct()Constructor.UnauthorizedHttpException
getName()HttpException
public function __construct(string|null $message = null, int $code = 0, Throwable|null $previous = null)

Constructor.

Parameters

ParameterTypeDescription
$messagestring|nullError message
$codeintError code
$previousThrowable|nullThe previous exception used for the exception chaining.