UnauthorizedException
mach::UnauthorizedException
Represents an HTTP 401 (Unauthorized) exception.
Description
Section titled “Description”UnauthorizedException indicates that a request requires authentication or that the provided authentication credentials are invalid. It is typically thrown when a client attempts to access a protected resource without successfully authenticating.
UnauthorizedException derives from HttpException.
Headers
Section titled “Headers”Primary header:
#include <mach/exceptions/UnauthorizedException.hpp>Convenience header:
#include <mach/exceptions.hpp>Syntax
Section titled “Syntax”class UnauthorizedException final : public HttpException {public: explicit UnauthorizedException( std::string message = "Authentication is required to access this resource." );};HTTP Status
Section titled “HTTP Status”| Property | Value |
|---|---|
| Code | 401 |
| Status | Unauthorized |
Member Functions
Section titled “Member Functions”UnauthorizedException inherits the public member functions of HttpException.
Remarks
Section titled “Remarks”The exception message defaults to "Authentication is required to access this resource." when no message is provided.
Example
Section titled “Example”throw mach::UnauthorizedException();See Also
Section titled “See Also”| Name | Description |
|---|---|
HttpException |
Base class for Mach HTTP exceptions. |
BadRequestException |
Represents an HTTP 400 Bad Request. |
ForbiddenException |
Represents an HTTP 403 Forbidden. |
NotFoundException |
Represents an HTTP 404 Not Found. |
ConflictException |
Represents an HTTP 409 Conflict. |