Class Catch
- Namespace
- Cratis.Monads
- Assembly
- Cratis.Fundamentals.dll
Represents the result of trying an execution that potentially produce an Exception.
public class Catch : OneOfBase<None, Exception>, IOneOf
- Inheritance
-
Catch
- Implements
-
IOneOf
- Inherited Members
-
OneOfBase<None, Exception>.TryPickT0(out None, out Exception)OneOfBase<None, Exception>.TryPickT1(out Exception, out None)OneOfBase<None, Exception>.ToString()OneOfBase<None, Exception>.GetHashCode()OneOfBase<None, Exception>.ValueOneOfBase<None, Exception>.IndexOneOfBase<None, Exception>.IsT0OneOfBase<None, Exception>.IsT1OneOfBase<None, Exception>.AsT0OneOfBase<None, Exception>.AsT1
- Extension Methods
Properties
IsSuccess
Gets a value indicating whether the execution was successful.
public bool IsSuccess { get; }
Property Value
Methods
Failed(Exception)
Creates a failed Catch.
public static Catch Failed(Exception error)
Parameters
errorExceptionThe error.
Returns
Failed<TResult>(Exception)
Creates a failed Catch<TResult>.
public static Catch<TResult> Failed<TResult>(Exception error)
Parameters
errorExceptionThe optional error.
Returns
- Catch<TResult>
The created Result<TError>.
Type Parameters
TResultThe type of the result.
Failed<TResult, TError>(Exception)
Creates a failed Catch<TResult, TError>.
public static Catch<TResult, TError> Failed<TResult, TError>(Exception error)
Parameters
errorExceptionThe error.
Returns
- Catch<TResult, TError>
The created Result<TResult, TError>.
Type Parameters
TResultThe result type.
TErrorThe error type.
Failed<TResult, TError>(TError)
Creates a failed Catch<TResult, TError>.
public static Catch<TResult, TError> Failed<TResult, TError>(TError error)
Parameters
errorTErrorThe error.
Returns
- Catch<TResult, TError>
The created Result<TResult, TError>.
Type Parameters
TResultThe result type.
TErrorThe error type.
RethrowError()
Rethrows the Exception error if any, preserving the correct stack trace.
public void RethrowError()
Success()
Creates a successful Catch.
public static Catch Success()
Returns
Success<TResult>(TResult)
Creates a successful Catch<TResult>.
public static Catch<TResult> Success<TResult>(TResult result)
Parameters
resultTResultThe result.
Returns
Type Parameters
TResultThe type of the result.
Success<TResult, TError>(TResult)
Creates a successful Catch<TResult, TError>.
public static Catch<TResult, TError> Success<TResult, TError>(TResult value)
Parameters
valueTResultThe value.
Returns
- Catch<TResult, TError>
The created Result<TResult, TError>.
Type Parameters
TResultThe result type.
TErrorThe error type.
TryGetException(out Exception?)
Try to get the error.
public bool TryGetException(out Exception? error)
Parameters
errorExceptionThe optional error.
Returns
- bool
A boolean indicating whether the error was present.
Operators
explicit operator Exception(Catch)
public static explicit operator Exception(Catch obj)
Parameters
objCatch
Returns
implicit operator Catch(Exception)
public static implicit operator Catch(Exception error)
Parameters
errorException