Class UnauthorizedError
- Namespace
- FunctionalDdd
- Assembly
- FunctionalDdd.RailwayOrientedProgramming.dll
Represents an authorization error when authentication is required but not provided. Use this when a user is not authenticated (not logged in) and must authenticate to access the resource. Maps to HTTP 401 Unauthorized.
public sealed class UnauthorizedError : Error, IEquatable<Error>
- Inheritance
-
UnauthorizedError
- Implements
- Inherited Members
- Extension Methods
Examples
Error.Unauthorized("Authentication required")
Error.Unauthorized("Invalid or expired authentication token")
Error.Unauthorized("Session has expired. Please log in again")
Remarks
Despite the HTTP status name, this error indicates missing or invalid authentication credentials. For authenticated users who lack permission, use ForbiddenError instead.
Common scenarios: - Missing authentication token - Expired or invalid credentials - Authentication session has ended
Constructors
UnauthorizedError(string, string, string?)
Initializes a new instance of the UnauthorizedError class.
public UnauthorizedError(string detail, string code, string? instance = null)