Unauthorized
extends Exception
in package
Exception thrown when authentication is required but not provided or invalid.
This exception should be thrown when a user needs to authenticate to access a resource. It corresponds to HTTP 401 Unauthorized status code.
Tags
Table of Contents
Properties
- $realm : string|null
Methods
- __construct() : mixed
- getRealm() : string|null
- Get the authentication realm if specified
Properties
$realm
private
string|null
$realm
Methods
__construct()
public
__construct([string $message = 'Authentication required' ][, string|null $realm = null ][, int $code = 401 ][, Throwable|null $previous = null ]) : mixed
Parameters
- $message : string = 'Authentication required'
-
The error message
- $realm : string|null = null
-
Optional authentication realm (e.g., for WWW-Authenticate header)
- $code : int = 401
-
The exception code (defaults to 401)
- $previous : Throwable|null = null
-
Previous exception for chaining
getRealm()
Get the authentication realm if specified
public
getRealm() : string|null