Class ConversionError
Represents an error that occurred during implicit type conversion. This error is used when implicit operators receive invalid input (null, empty collections, etc.) instead of throwing exceptions, keeping the API consistent with the Result pattern philosophy.
public class ConversionError : Reason<ConversionError>, IError, IReason
- Inheritance
-
ConversionError
- Implements
- Inherited Members
- Extension Methods
Remarks
ConversionError is automatically created in these scenarios:
- Null error provided to implicit conversion
- Empty error array provided to implicit conversion
- Empty error list provided to implicit conversion
Constructors
ConversionError(string)
Creates a new ConversionError with the specified reason. Automatically tags the error as a conversion error with Warning severity.
public ConversionError(string reason)
Parameters
reasonstring
Methods
CreateNew(string, ImmutableDictionary<string, object>)
Creates a new ConversionError with updated message and tags (CRTP pattern).
protected override ConversionError CreateNew(string message, ImmutableDictionary<string, object> tags)
Parameters
messagestringtagsImmutableDictionary<string, object>
Returns
WithConversionType(string)
Adds conversion-specific context to the error. Returns ConversionError for fluent chaining.
public ConversionError WithConversionType(string conversionType)
Parameters
conversionTypestring
Returns
WithProvidedValue(object?)
Adds the provided value to error context. Returns ConversionError for fluent chaining.
public ConversionError WithProvidedValue(object? value)
Parameters
valueobject