LanguageExt.Core

LanguageExt.Core Prelude Catch

Contents

class Prelude Source #

The @catch functions produce a CatchError or CatchValue type. These can be composed together with the Aff and Eff monads (and maybe more in the future), to create a functional-programming equivalent to exception catching and matching.

Examples

 public class TimeoutExample<RT>
     where RT : struct,
     HasTime<RT>,
     HasCancel<RT>,
     HasConsole<RT>
 {
     public static Aff<RT, Unit> main =>
         from _1 in timeout(60 * seconds, longRunning)
                  | @catch(Errors.TimedOut, unit)
         from _2 in Console<RT>.writeLine("done")
         select unit;

     static Aff<RT, Unit> longRunning =>
         (from tm in Time<RT>.now
          from _1 in Console<RT>.writeLine(tm.ToLongTimeString())
          select unit)
        .ToAff()
        .Repeat(Schedule.Fibonacci(1 * second));
 }

Methods

method CatchValue<A> @catch <A> (Error error, Func<Error, A> Fail) Source #

Catch an error if the error matches the argument provided

method CatchError @catch (Error error, Func<Error, Error> Fail) Source #

Catch an error if the error matches the argument provided

method CatchValue<A> @catch <A> (Error error, A Fail) Source #

Catch an error if the error matches the argument provided

method CatchError @catch (Error error, Error Fail) Source #

Catch an error if the error matches the argument provided

method CatchValue<A> @catch <A> (int errorCode, Func<Error, A> Fail) Source #

Catch an error if the error Code matches the errorCode argument provided

method CatchError @catch (int errorCode, Func<Error, Error> Fail) Source #

Catch an error if the error Code matches the errorCode argument provided

method CatchValue<A> @catch <A> (int errorCode, A Fail) Source #

Catch an error if the error Code matches the errorCode argument provided

method CatchError @catch (int errorCode, Error Fail) Source #

Catch an error if the error Code matches the errorCode argument provided

method CatchValue<A> @catch <A> (string errorText, Func<Error, A> Fail) Source #

Catch an error if the error message matches the errorText argument provided

method CatchError @catch (string errorText, Func<Error, Error> Fail) Source #

Catch an error if the error message matches the errorText argument provided

method CatchValue<A> @catch <A> (string errorText, A Fail) Source #

Catch an error if the error message matches the errorText argument provided

method CatchError @catch (string errorText, Error Fail) Source #

Catch an error if the error message matches the errorText argument provided

method CatchValue<A> @catch <A> (Func<Exception, bool> predicate, Func<Exception, A> Fail) Source #

Catch an error if it's of a specific exception type

method CatchError @catch (Func<Exception, bool> predicate, Func<Exception, Error> Fail) Source #

Catch an error if it's of a specific exception type

method CatchValue<A> @catch <A> (Func<Exception, bool> predicate, A Fail) Source #

Catch an error if it's of a specific exception type

method CatchError @catch (Func<Exception, bool> predicate, Error Fail) Source #

Catch an error if it's of a specific exception type

method CatchError @catch (Error Fail) Source #

Catch all errors and return Fail

method CatchValue<A> @catch <A> (A Fail) Source #

Catch all errors and return Fail

method CatchValue<A> @catchOf <E, A> (Func<E, A> Fail) Source #

where E : Error

Catch errors

method CatchError @catchOf <E> (Func<E, Error> Fail) Source #

where E : Error

Catch errors

method CatchValue<A> @expected <A> (Func<Expected, A> Fail) Source #

Catch expected errors

method CatchError @expected (Func<Expected, Error> Fail) Source #

Catch expected errors

method CatchValue<A> @expectedOf <E, A> (Func<E, A> Fail) Source #

where E : Expected

Catch expected errors

method CatchError @expectedOf <E> (Func<E, Error> Fail) Source #

where E : Expected

Catch expected errors

method CatchValue<A> @exceptional <A> (Func<Exceptional, A> Fail) Source #

Catch exceptional errors

method CatchError @exceptional (Func<Exceptional, Error> Fail) Source #

Catch exceptional errors

method CatchValue<A> @exceptionalOf <E, A> (Func<E, A> Fail) Source #

where E : Exceptional

Catch exceptional errors

method CatchError @exceptionalOf <E> (Func<E, Error> Fail) Source #

where E : Exceptional

Catch exceptional errors