Table of Contents

Class PreconditionFailedError

Namespace
Trellis
Assembly
Trellis.Results.dll

Represents a precondition failure per RFC 9110 ยง13.1.1. The server will not perform the request because a condition in the request headers (e.g., If-Match, If-None-Match) evaluated to false. Maps to HTTP 412 Precondition Failed.

public sealed class PreconditionFailedError : Error, IEquatable<Error>
Inheritance
PreconditionFailedError
Implements
Inherited Members
Extension Methods

Examples

Error.PreconditionFailed("Resource has been modified. Please reload and retry.")
Error.PreconditionFailed("ETag mismatch โ€” expected \"abc123\" but resource has \"def456\"")

Remarks

Common scenarios include: - If-Match ETag mismatch โ€” the resource has been modified since the client last retrieved it - If-None-Match failure on non-safe methods โ€” the resource already exists - Optimistic concurrency failure when the client provides a stale ETag

This is distinct from ConflictError (409), which indicates a state-based conflict without a client-supplied precondition (e.g., duplicate key, FK violation). PreconditionFailedError specifically signals that a conditional header was present and the condition was not met.

Constructors

PreconditionFailedError(string, string, string?)

Initializes a new instance of the PreconditionFailedError class.

public PreconditionFailedError(string detail, string code, string? instance = null)

Parameters

detail string

Description of the precondition failure.

code string

The error code identifying this type of precondition error.

instance string

Optional identifier for the affected resource.