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
CodestringNon-blank machine-readable code describing the kind of conflict (e.g. DuplicateKey,
"invalid-state").ResourceResourceRef?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
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
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
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
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
codestringNon-blank machine-readable code describing the kind of conflict.
resourceResourceRefThe conflicting resource.
detailstringOptional 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
codestringNon-blank machine-readable code describing the kind of conflict.
detailstringOptional 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
codestringNon-blank machine-readable code describing the kind of conflict.
idobjectOptional identifier of the conflicting instance; omit for a collection-level conflict, or use ForReason(string, string?).
detailstringOptional human-readable detail.
Returns
- Error.Conflict
A Error.Conflict for the resource.
Type Parameters
TResourceThe conflicting resource type.