Class UnauthorizedError
Represents an authentication error (HTTP 401 equivalent). Use when the caller is not authenticated or credentials are invalid.
public class UnauthorizedError : Reason<UnauthorizedError>, IReasonMetadata, IError, IReason, IErrorFactory<UnauthorizedError>
- Inheritance
-
UnauthorizedError
- Implements
- Inherited Members
- Extension Methods
Examples
Result<User>.Fail(new UnauthorizedError());
Result<User>.Fail(new UnauthorizedError("Token has expired"));
Constructors
UnauthorizedError()
public UnauthorizedError()
UnauthorizedError(string, string?, string?, int)
public UnauthorizedError(string message, string? callerMember = null, string? callerFile = null, int callerLine = 0)
Parameters
Methods
Create(string)
Creates an instance of UnauthorizedError with the given message.
public static UnauthorizedError Create(string message)
Parameters
messagestring
Returns
CreateNew(string, ImmutableDictionary<string, object>)
Factory method for creating new instances (maintains immutability). Must be implemented by derived classes.
protected override UnauthorizedError CreateNew(string message, ImmutableDictionary<string, object> tags)
Parameters
messagestringtagsImmutableDictionary<string, object>