ExceptUtil Class

Utility function related to Exception, mostly to offer usability as expression.

Definition

Namespace: Karamba.Utilities
Assembly: KarambaCommon (in KarambaCommon.dll) Version: 3.0.8.0+eb23a7103f0eca0b6d808121e15fec6899194e15
C#
public static class ExceptUtil
Inheritance
Object    ExceptUtil

Methods

ConvertTrierToMaybeSayerTr(ExceptUtilTryXxxFuncTr) Convert function of the form "bool TryDoWhatever(..., out Tr res)" to Tr DoWhatever(...) which returns null in case of failure.
ConvertTrierToMaybeSayerTs, Tr(ExceptUtilTryXxxFuncTs, Tr)  
ConvertTrierToMaybeSayerTs1, Ts2, Tr(ExceptUtilTryXxxFuncTs1, Ts2, Tr)  
ConvertTrierToThrowerTr(ExceptUtilTryXxxFuncTr, String) Convert function of the form "bool TryDoWhatever(..., out Tr res)" to Tr DoWhatever(...). So both typical forms, can be offered without have to code it two times.
ConvertTrierToThrowerTs, Tr(ExceptUtilTryXxxFuncTs, Tr, String)  
ConvertTrierToThrowerTs1, Ts2, Tr(ExceptUtilTryXxxFuncTs1, Ts2, Tr, String)  
ConvertValTrierToMaybeSayerTr(ExceptUtilTryXxxFuncTr) just for value types.
ConvertValTrierToMaybeSayerTs, Tr(ExceptUtilTryXxxFuncTs, Tr)  
ConvertValTrierToMaybeSayerTs1, Ts2, Tr(ExceptUtilTryXxxFuncTs1, Ts2, Tr)  
IgnoreAllExceptions(Action) Ignore all exceptions of given function.
IgnoreAllExceptions(Object, Action)  
IgnoreAllExceptionsTr(FuncTr) Ignore all exceptions and return null instead.
IgnoreAllExceptionsTr(Object, FuncTr) Ignore all exceptions of a class returning class of type Tr.
IgnoreException(Action, String) Ignore exceptions of given names when thrown in the given function.
IgnoreExceptionTr(FuncTr, String) Ignore some exceptions and return null instead.
IgnoreExceptionExcept(Action, String) Ignore exceptions except some.
IgnoreExceptionExceptTr(FuncTr, String) Ignore exceptions except some and return null instead.
NullifyTr(FuncTr) Converts an exception to returning .
NullifyT1, Tr(FuncT1, Tr, T1)  
NullifyT1, T2, Tr(FuncT1, T2, Tr, T1, T2)  
TryToGetT(FuncT, FuncException, T, Action) try-expression. Instead of:
C#
ComplexButUninterestingType r; try { r = ...; } catch { ... }
just:
C#
var r = TryToGet(() => ..., ex => ...);
dot.
TryToGetT(FuncT, DictionaryString, FuncException, T, FuncException, T, Action) Try-expression with dictionary and fallback resolver.
UsingS, T Using Expression.
ValNullifyTr  
WithFinalizationT(FuncT, Action) Don't catch an exception, but ensure that final is called.
WithFinalizationS, T(S, FuncS, T, ActionS) Don't catch an exception, but ensure that final is called.

See Also