Class ConflictError

Namespace
REslava.Result
Assembly
REslava.Result.dll

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

entityName string
conflictField string
conflictValue object

ConflictError(string, string?, string?, int)

public ConflictError(string message, string? callerMember = null, string? callerFile = null, int callerLine = 0)

Parameters

message string
callerMember string
callerFile string
callerLine int

Methods

Create(string)

Creates an instance of ConflictError with the given message.

public static ConflictError Create(string message)

Parameters

message string

Returns

ConflictError

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

message string
tags ImmutableDictionary<string, object>

Returns

ConflictError

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

entityName string
conflictField string
conflictValue object
callerMember string
callerFile string
callerLine int

Returns

ConflictError

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

conflictField string
conflictValue object
callerMember string
callerFile string
callerLine int

Returns

ConflictError

Type Parameters

T