Class ConflictError
Represents a conflict error (HTTP 409 equivalent). Use when an operation conflicts with existing state (duplicates, version conflicts).
public class ConflictError : Reason<ConflictError>, IReasonMetadata, IError, IReason, IErrorFactory<ConflictError>
- Inheritance
-
ConflictError
- Implements
- Inherited Members
- Extension Methods
Examples
Result<User>.Fail(new ConflictError("User", "email", email));
Result<User>.Fail(new ConflictError("A user with this email already exists"));
Constructors
ConflictError(string, string, object)
[Obsolete("Use ConflictError.Duplicate(entity, field, value) instead — it also captures the calling step name.")]
public ConflictError(string entityName, string conflictField, object conflictValue)
Parameters
ConflictError(string, string?, string?, int)
public ConflictError(string message, string? callerMember = null, string? callerFile = null, int callerLine = 0)
Parameters
Methods
Create(string)
Creates an instance of ConflictError with the given message.
public static ConflictError Create(string message)
Parameters
messagestring
Returns
CreateNew(string, ImmutableDictionary<string, object>)
Factory method for creating new instances (maintains immutability). Must be implemented by derived classes.
protected override ConflictError CreateNew(string message, ImmutableDictionary<string, object> tags)
Parameters
messagestringtagsImmutableDictionary<string, object>
Returns
Duplicate(string, string, object, string?, string?, int)
Creates a conflict error for a duplicate field value, capturing the calling step name.
public static ConflictError Duplicate(string entityName, string conflictField, object conflictValue, string? callerMember = null, string? callerFile = null, int callerLine = 0)
Parameters
entityNamestringconflictFieldstringconflictValueobjectcallerMemberstringcallerFilestringcallerLineint
Returns
Duplicate<T>(string, object, string?, string?, int)
Creates a conflict error for a duplicate field value, inferring entity name from T.
public static ConflictError Duplicate<T>(string conflictField, object conflictValue, string? callerMember = null, string? callerFile = null, int callerLine = 0)
Parameters
Returns
Type Parameters
T