Table of Contents

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

Code ErrorCode

The typed error code for programmatic error handling.

Message string

The human-readable error message describing what went wrong.

Details IReadOnlyDictionary<string, string[]>

Optional field-level error details from RFC 7807 validation errors.

InnerException Exception

Optional inner exception providing additional context.

HttpStatusCode HttpStatusCode?

The HTTP status code if this error originated from an HTTP response.

RetryAfter TimeSpan?

The retry delay from the Retry-After header (typically for rate limiting).

TraceId string

The trace identifier for correlating with server logs.

Properties

Code

The typed error code for programmatic error handling.

public ErrorCode Code { get; init; }

Property Value

ErrorCode

Details

Optional field-level error details from RFC 7807 validation errors.

public IReadOnlyDictionary<string, string[]>? Details { get; init; }

Property Value

IReadOnlyDictionary<string, string[]>

HttpStatusCode

The HTTP status code if this error originated from an HTTP response.

public HttpStatusCode? HttpStatusCode { get; init; }

Property Value

HttpStatusCode?

InnerException

Optional inner exception providing additional context.

public Exception? InnerException { get; init; }

Property Value

Exception

Message

The human-readable error message describing what went wrong.

public string Message { get; init; }

Property Value

string

RetryAfter

The retry delay from the Retry-After header (typically for rate limiting).

public TimeSpan? RetryAfter { get; init; }

Property Value

TimeSpan?

TraceId

The trace identifier for correlating with server logs.

public string? TraceId { get; init; }

Property Value

string

Methods

Create(ErrorCode, string)

Creates an error with the specified code and message.

public static Error Create(ErrorCode code, string message)

Parameters

code ErrorCode

The error code.

message string

The error message.

Returns

Error

A new Error instance.

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

code ErrorCode

The error code.

message string

The error message.

innerException Exception

The inner exception.

Returns

Error

A new Error instance.