Class Error
- Namespace
- LightResults
- Assembly
- LightResults.dll
Represents an error with a message and associated metadata.
public class Error : IError, IEquatable<Error>
Inheritance
Implements
Inherited Members
Constructors
Error()
Initializes a new instance of the LightResults.Error class.
public Error()
Error(string)
Initializes a new instance of the LightResults.Error class with the specified error message.
public Error(string message)
Parameters
message
string-
The error message.
Error(Exception?)
Initializes a new instance of the LightResults.Error class with the specified exception.
public Error(Exception? exception)
Parameters
exception
Exception?-
The LightResults.Error.Exception associated with the error.
Remarks
The exception
is added to LightResults.Error.Metadata under the key of "Exception" and the LightResults.Error.Message is set to the exception message if present.
Error(string, Exception?)
Initializes a new instance of the LightResults.Error class with the specified error message and exception.
public Error(string message, Exception? exception)
Parameters
message
string-
The error message.
exception
Exception?-
The LightResults.Error.Exception associated with the error.
Remarks
The exception
is added to LightResults.Error.Metadata under the key of "Exception".
Error(string, (string Key, object? Value))
Initializes a new instance of the LightResults.Error class with the specified error message and metadata.
public Error(string message, (string Key, object? Value) metadata)
Parameters
message
string-
The error message.
metadata
(string Key, object? Value)-
The metadata associated with the error.
Error(string, KeyValuePair<string, object?>)
Initializes a new instance of the LightResults.Error class with the specified error message and metadata.
public Error(string message, KeyValuePair<string, object?> metadata)
Parameters
message
string-
The error message.
metadata
KeyValuePair<string, object?>-
The metadata associated with the error.
Error(string, IEnumerable<KeyValuePair<string, object?>>)
Initializes a new instance of the LightResults.Error class with the specified error message and metadata.
public Error(string message, IEnumerable<KeyValuePair<string, object?>> metadata)
Parameters
message
string-
The error message.
metadata
IEnumerable<KeyValuePair<string, object?>>-
The metadata associated with the error.
Error(string, IReadOnlyDictionary<string, object?>)
Initializes a new instance of the LightResults.Error class with the specified error message and metadata.
public Error(string message, IReadOnlyDictionary<string, object?> metadata)
Parameters
message
string-
The error message.
metadata
IReadOnlyDictionary<string, object?>-
The metadata associated with the error.
Properties
Empty
Gets an empty LightResults.Error instance.
public static IError Empty { get; }
Property Value
Exception
Gets the LightResults.IError.Exception associated with the error if one exists.
public Exception? Exception { get; }
Property Value
Message
Gets the error message.
public string Message { get; init; }
Property Value
Metadata
Gets the metadata associated with the error.
public IReadOnlyDictionary<string, object?> Metadata { get; init; }
Property Value
Remarks
The metadata is represented as a read-only dictionary of key-value pairs, where the keys are System.String and the values are System.Object which may be null.
Methods
Equals(Error?)
Determines whether the specified LightResults.Error is equal to this instance.
public bool Equals(Error? other)
Parameters
other
Error?-
The LightResults.Error to compare with this instance.
Returns
- bool
-
true
if the specified LightResults.Error is equal to this instance; otherwise,false
.
Equals(object?)
Determines whether the specified object is equal to the current object.
public override bool Equals(object? obj)
Parameters
obj
object?-
The object to compare with the current object.
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
-
A hash code for the current object.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
-
A string that represents the current object.
Operators
operator ==(Error?, Error?)
Determines whether two LightResults.Error instances are equal.
public static bool operator ==(Error? left, Error? right)
Parameters
left
Error?-
The first LightResults.Error instance to compare.
right
Error?-
The second LightResults.Error instance to compare.
Returns
- bool
-
true
if the specified LightResults.Error instances are equal; otherwise,false
.
operator !=(Error?, Error?)
Determines whether two LightResults.Error instances are not equal.
public static bool operator !=(Error? left, Error? right)
Parameters
left
Error?-
The first LightResults.Error instance to compare.
right
Error?-
The second LightResults.Error instance to compare.
Returns
- bool
-
true
if the specified LightResults.Error instances are not equal; otherwise,false
.