LanguageExt.Core

LanguageExt.Core Utility ExceptionMatch

Contents

class ExceptionMatch <R> Source #

Pattern matching for exceptions. This is to aid expression based error handling.

Examples

ex.Match<string>()
  .With<SystemException>(e => "It's a system exception")
  .With<ArgumentNullException>(e => "Arg null")
  .Otherwise("Not handled")

Methods

method ExceptionMatch<R> With <TException> (Func<TException, R> map) Source #

where TException : Exception

Matches a typed exception with a mapping function

Parameters

type TException
param map

Function to map the exception to a result value

returns

Matching context - you must use 'Otherwise()' to invoke

method R OtherwiseReThrow () Source #

Invokes the match expression and provides a default value if nothing matches

Parameters

returns

Result of the expression

method R Otherwise (R otherwiseValue) Source #

Invokes the match expression and provides a default value if nothing matches

Parameters

param otherwiseValue

Default value

returns

Result of the expression

method R Otherwise (Func<R> otherwise) Source #

Invokes the match expression and provides a default function to invoke if nothing matches

Parameters

param otherwise

Default value

returns

Result of the expression

method R Otherwise (Func<Exception, R> otherwiseMap) Source #

Invokes the match expression and provides a default function to invoke if nothing matches

Parameters

param otherwiseMap

Default value

returns

Result of the expression

class ExceptionExtensions Source #

Exception extensions

Methods

method LanguageExt.ExceptionMatch<R> Match <R> (this Exception self) Source #

Pattern matching for exceptions. This is to aid expression based error handling.

Examples

ex.Match<string>()
  .With<SystemException>(e => "It's a system exception")
  .With<ArgumentNullException>(e => "Arg null")
  .Otherwise("Not handled")

method Unit Rethrow (this Exception exception) Source #

Rethrows the exception whilst maintaining its original context

Unwraps any inner exceptions

Parameters

param exception

Exception to rethrow

method A Rethrow <A> (this Exception exception) Source #

Rethrows the exception whilst maintaining its original context

Unwraps any inner exceptions

Parameters

param exception

Exception to rethrow

class ExceptionMatchAsync <R> Source #

Pattern matching for exceptions. This is to aid expression based error handling.

Examples

ex.Match<string>()
  .With<SystemException>(e => "It's a system exception")
  .With<ArgumentNullException>(e => "Arg null")
  .Otherwise("Not handled")

Methods

method ExceptionMatchAsync<R> With <TException> (Func<TException, R> map) Source #

where TException : Exception

Matches a typed exception with a mapping function

Parameters

type TException
param map

Function to map the exception to a result value

returns

Matching context - you must use 'Otherwise()' to invoke

method Task<R> OtherwiseReThrow () Source #

Invokes the match expression and provides a default value if nothing matches

Parameters

returns

Result of the expression

method Task<R> Otherwise (R otherwiseValue) Source #

Invokes the match expression and provides a default value if nothing matches

Parameters

param otherwiseValue

Default value

returns

Result of the expression

method Task<R> Otherwise (Func<R> otherwise) Source #

Invokes the match expression and provides a default function to invoke if nothing matches

Parameters

param otherwise

Default value

returns

Result of the expression

method Task<R> Otherwise (Func<Exception, R> otherwiseMap) Source #

Invokes the match expression and provides a default function to invoke if nothing matches

Parameters

param otherwiseMap

Default value

returns

Result of the expression

class ExceptionAsyncExtensions Source #

Exception extensions

Methods

method LanguageExt.ExceptionMatchAsync<R> Match <R> (this Task<Result<R>> self) Source #

Pattern matching for exceptions. This is to aid expression based error handling.

Examples

tr.Match<string>()
  .With<SystemException>(e => "It's a system exception")
  .With<ArgumentNullException>(e => "Arg null")
  .Otherwise("Not handled")

class ExceptionMatchOptionalAsync <R> Source #

Pattern matching for exceptions. This is to aid expression based error handling.

Examples

ex.Match<string>()
  .With<SystemException>(e => "It's a system exception")
  .With<ArgumentNullException>(e => "Arg null")
  .Otherwise("Not handled")

Methods

method ExceptionMatchOptionalAsync<R> With <TException> (Func<TException, R> map) Source #

where TException : Exception

Matches a typed exception with a mapping function

Parameters

type TException
param map

Function to map the exception to a result value

returns

Matching context - you must use 'Otherwise()' to invoke

method Task<Option<R>> OtherwiseReThrow () Source #

Invokes the match expression and provides a default value if nothing matches

Parameters

returns

Result of the expression

method Task<Option<R>> Otherwise (R otherwiseValue) Source #

Invokes the match expression and provides a default value if nothing matches

Parameters

param otherwiseValue

Default value

returns

Result of the expression

method Task<Option<R>> Otherwise (Func<R> otherwise) Source #

Invokes the match expression and provides a default function to invoke if nothing matches

Parameters

param otherwise

Default value

returns

Result of the expression

method Task<Option<R>> Otherwise (Func<Exception, R> otherwiseMap) Source #

Invokes the match expression and provides a default function to invoke if nothing matches

Parameters

param otherwiseMap

Default value

returns

Result of the expression

class ExceptionOptionalAsyncExtensions Source #

Exception extensions

Methods

method LanguageExt.ExceptionMatchOptionalAsync<R> Match <R> (this Task<OptionalResult<R>> self) Source #

Pattern matching for exceptions. This is to aid expression based error handling.

Examples

tr.Match<string>()
  .With<SystemException>(e => "It's a system exception")
  .With<ArgumentNullException>(e => "Arg null")
  .Otherwise("Not handled")