Class TryBuilder
Represents structured exception handling statement.
Inherited Members
Namespace: DotNext.Metaprogramming
Assembly: DotNext.Metaprogramming.dll
Syntax
public sealed class TryBuilder : ExpressionBuilder<TryExpression>, ISupplier<TryExpression>, IFunctional<Func<TryExpression>>
Methods
| Edit this page View SourceCatch(Action)
Constructs exception handling section that may capture any exception.
Declaration
public TryBuilder Catch(Action handler)
Parameters
Type | Name | Description |
---|---|---|
Action | handler | Exception handling block. |
Returns
Type | Description |
---|---|
TryBuilder | Structured exception handler. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Attempts to call this method out of lexical scope. |
Catch(Expression)
Constructs exception handling clause that can capture any exception.
Declaration
public TryBuilder Catch(Expression handler)
Parameters
Type | Name | Description |
---|---|---|
Expression | handler | The expression representing exception handling clause. |
Returns
Type | Description |
---|---|
TryBuilder |
|
Catch(Type, Filter?, Handler)
Constructs exception handling section.
Declaration
public TryBuilder Catch(Type exceptionType, TryBuilder.Filter? filter, TryBuilder.Handler handler)
Parameters
Type | Name | Description |
---|---|---|
Type | exceptionType | Expected exception. |
TryBuilder.Filter | filter | Additional filter to be applied to the caught exception. |
TryBuilder.Handler | handler | Exception handling block. |
Returns
Type | Description |
---|---|
TryBuilder |
|
Catch(Type, Filter?, Action<ParameterExpression>)
Constructs exception handling section.
Declaration
public TryBuilder Catch(Type exceptionType, TryBuilder.Filter? filter, Action<ParameterExpression> handler)
Parameters
Type | Name | Description |
---|---|---|
Type | exceptionType | Expected exception. |
TryBuilder.Filter | filter | Additional filter to be applied to the caught exception. |
Action<ParameterExpression> | handler | Exception handling block. |
Returns
Type | Description |
---|---|
TryBuilder | Structured exception handler builder. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Attempts to call this method out of lexical scope. |
Catch(Type, Handler)
Constructs exception handling clause.
Declaration
public TryBuilder Catch(Type exceptionType, TryBuilder.Handler handler)
Parameters
Type | Name | Description |
---|---|---|
Type | exceptionType | Expected exception. |
TryBuilder.Handler | handler | Exception handling block. |
Returns
Type | Description |
---|---|
TryBuilder |
|
Catch(Type, Action)
Constructs exception handling section.
Declaration
public TryBuilder Catch(Type exceptionType, Action handler)
Parameters
Type | Name | Description |
---|---|---|
Type | exceptionType | Expected exception. |
Action | handler | Exception handling block. |
Returns
Type | Description |
---|---|
TryBuilder | Structured exception handler. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Attempts to call this method out of lexical scope. |
Catch(Type, Action<ParameterExpression>)
Constructs exception handling section.
Declaration
public TryBuilder Catch(Type exceptionType, Action<ParameterExpression> handler)
Parameters
Type | Name | Description |
---|---|---|
Type | exceptionType | Expected exception. |
Action<ParameterExpression> | handler | Exception handling block. |
Returns
Type | Description |
---|---|
TryBuilder | Structured exception handler. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Attempts to call this method out of lexical scope. |
Catch<TException>(Handler)
Constructs exception handling clause.
Declaration
public TryBuilder Catch<TException>(TryBuilder.Handler handler) where TException : Exception
Parameters
Type | Name | Description |
---|---|---|
TryBuilder.Handler | handler | Exception handling block. |
Returns
Type | Description |
---|---|
TryBuilder |
|
Type Parameters
Name | Description |
---|---|
TException | Expected exception. |
Catch<TException>(Action)
Constructs exception handling section.
Declaration
public TryBuilder Catch<TException>(Action handler) where TException : Exception
Parameters
Type | Name | Description |
---|---|---|
Action | handler | Exception handling block. |
Returns
Type | Description |
---|---|
TryBuilder | Structured exception handler. |
Type Parameters
Name | Description |
---|---|
TException | Expected exception. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Attempts to call this method out of lexical scope. |
Catch<TException>(Action<ParameterExpression>)
Constructs exception handling section.
Declaration
public TryBuilder Catch<TException>(Action<ParameterExpression> handler) where TException : Exception
Parameters
Type | Name | Description |
---|---|---|
Action<ParameterExpression> | handler | Exception handling block. |
Returns
Type | Description |
---|---|
TryBuilder | Structured exception handler. |
Type Parameters
Name | Description |
---|---|
TException | Expected exception. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Attempts to call this method out of lexical scope. |
Fault(Action)
Constructs block of code which will be executed in case of any exception.
Declaration
public TryBuilder Fault(Action fault)
Parameters
Type | Name | Description |
---|---|---|
Action | fault | Fault handling block. |
Returns
Type | Description |
---|---|
TryBuilder |
|
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Attempts to call this method out of lexical scope. |
Fault(Expression)
Associates expression to be returned from structured exception handling block in case of any exception.
Declaration
public TryBuilder Fault(Expression fault)
Parameters
Type | Name | Description |
---|---|---|
Expression | fault | The expression to be returned from SEH block. |
Returns
Type | Description |
---|---|
TryBuilder |
|
Finally(Action)
Constructs block of code run when control leaves a try
statement.
Declaration
public TryBuilder Finally(Action body)
Parameters
Type | Name | Description |
---|---|---|
Action | body | The block of code to be executed. |
Returns
Type | Description |
---|---|
TryBuilder |
|
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Attempts to call this method out of lexical scope. |
Finally(Expression)
Constructs single expression run when control leaves a try
statement.
Declaration
public TryBuilder Finally(Expression @finally)
Parameters
Type | Name | Description |
---|---|---|
Expression | finally | The single expression to be executed. |
Returns
Type | Description |
---|---|
TryBuilder |
|