Table of Contents

Class Error.Conflict

Namespace
Trellis
Assembly
Trellis.Core.dll

The request conflicts with the current state of the resource.

public sealed record Error.Conflict : Error, IEquatable<Error>, IEquatable<Error.Conflict>
Inheritance
Error.Conflict
Implements
Inherited Members
Extension Methods

Constructors

Conflict(string, ResourceRef?)

The request conflicts with the current state of the resource.

public Conflict(string Code, ResourceRef? Resource = null)

Parameters

Code string

Non-blank machine-readable code describing the kind of conflict (e.g. DuplicateKey, "invalid-state").

Resource ResourceRef?

The conflicting resource, when one is identifiable. May be null for stateless conflicts (e.g. workflow / state-machine guards, library code with no aggregate context).

Properties

ConstraintName

Optional provider-reported constraint name when the conflict came from a database constraint violation (unique index, primary key, or foreign key). Populated on a best-effort basis by helpers such as DbContext.TryInsertUniqueAsync and DbContext.SaveChangesResultAsync; null for non-database conflicts or when the provider does not surface the name.

[JsonIgnore]
public string? ConstraintName { get; init; }

Property Value

string

Remarks

Telemetry-only. The value can reveal schema details (index names, constraint names) and is therefore excluded from default System.Text.Json serialization via JsonIgnoreAttribute. Use it for structured logging and observability dimensions; do not surface it directly in API responses.

ConstraintTableName

Optional provider-reported table name associated with ConstraintName, when the provider surfaces it. null otherwise.

[JsonIgnore]
public string? ConstraintTableName { get; init; }

Property Value

string

Remarks

Telemetry-only with the same handling as ConstraintName: excluded from default JSON serialization and unsuitable for API responses.

Kind

Gets the stable domain slug for this case (e.g. "not-found", "invalid-input"). Suitable for telemetry, observability dimensions, and as the durable identifier that boundary layers translate into transport-specific type identifiers.

public override string Kind { get; }

Property Value

string

Resource

The conflicting resource, when one is identifiable. May be null for stateless conflicts (e.g. workflow / state-machine guards, library code with no aggregate context).

public ResourceRef? Resource { get; init; }

Property Value

ResourceRef?

Methods

For(string, ResourceRef, string?)

Convenience factory that builds a Error.Conflict from an explicit resource reference.

public static Error.Conflict For(string code, ResourceRef resource, string? detail = null)

Parameters

code string

Non-blank machine-readable code describing the kind of conflict.

resource ResourceRef

The conflicting resource.

detail string

Optional human-readable detail.

Returns

Error.Conflict

A Error.Conflict for the resource.

ForReason(string, string?)

Convenience factory for a stateless conflict with no identifiable resource (e.g. a workflow / state-machine guard, or library code with no aggregate context).

public static Error.Conflict ForReason(string code, string? detail = null)

Parameters

code string

Non-blank machine-readable code describing the kind of conflict.

detail string

Optional human-readable detail.

Returns

Error.Conflict

A resourceless Error.Conflict.

For<TResource>(string, object?, string?)

Convenience factory that builds a Error.Conflict against the resource type TResource (its CLR name becomes the resource name).

public static Error.Conflict For<TResource>(string code, object? id = null, string? detail = null)

Parameters

code string

Non-blank machine-readable code describing the kind of conflict.

id object

Optional identifier of the conflicting instance; omit for a collection-level conflict, or use ForReason(string, string?).

detail string

Optional human-readable detail.

Returns

Error.Conflict

A Error.Conflict for the resource.

Type Parameters

TResource

The conflicting resource type.