Class Error
- Namespace
- CivitaiSharp.Core.Response
- Assembly
- CivitaiSharp.Core.dll
Represents an error encountered during an operation. Contains a typed ErrorCode for programmatic handling, plus a human-readable message and optional context for diagnostics. Use pattern matching on Code to handle specific error conditions, and check Details for field-level validation errors.
public sealed record Error : IEquatable<Error>
- Inheritance
-
Error
- Implements
- Inherited Members
Constructors
Error(ErrorCode, string, IReadOnlyDictionary<string, string[]>?, Exception?, HttpStatusCode?, TimeSpan?, string?)
Represents an error encountered during an operation. Contains a typed ErrorCode for programmatic handling, plus a human-readable message and optional context for diagnostics. Use pattern matching on Code to handle specific error conditions, and check Details for field-level validation errors.
public Error(ErrorCode Code, string Message, IReadOnlyDictionary<string, string[]>? Details = null, Exception? InnerException = null, HttpStatusCode? HttpStatusCode = null, TimeSpan? RetryAfter = null, string? TraceId = null)
Parameters
CodeErrorCodeThe typed error code for programmatic error handling.
MessagestringThe human-readable error message describing what went wrong.
DetailsIReadOnlyDictionary<string, string[]>Optional field-level error details from RFC 7807 validation errors.
InnerExceptionExceptionOptional inner exception providing additional context.
HttpStatusCodeHttpStatusCode?The HTTP status code if this error originated from an HTTP response.
RetryAfterTimeSpan?The retry delay from the Retry-After header (typically for rate limiting).
TraceIdstringThe trace identifier for correlating with server logs.
Properties
Code
The typed error code for programmatic error handling.
public ErrorCode Code { get; init; }
Property Value
Details
Optional field-level error details from RFC 7807 validation errors.
public IReadOnlyDictionary<string, string[]>? Details { get; init; }
Property Value
HttpStatusCode
The HTTP status code if this error originated from an HTTP response.
public HttpStatusCode? HttpStatusCode { get; init; }
Property Value
InnerException
Optional inner exception providing additional context.
public Exception? InnerException { get; init; }
Property Value
Message
The human-readable error message describing what went wrong.
public string Message { get; init; }
Property Value
RetryAfter
The retry delay from the Retry-After header (typically for rate limiting).
public TimeSpan? RetryAfter { get; init; }
Property Value
TraceId
The trace identifier for correlating with server logs.
public string? TraceId { get; init; }
Property Value
Methods
Create(ErrorCode, string)
Creates an error with the specified code and message.
public static Error Create(ErrorCode code, string message)
Parameters
Returns
Create(ErrorCode, string, Exception)
Creates an error with the specified code, message, and inner exception.
public static Error Create(ErrorCode code, string message, Exception innerException)
Parameters
codeErrorCodeThe error code.
messagestringThe error message.
innerExceptionExceptionThe inner exception.