Class TryBuilder
Represents structured exception handling statement.
Inherited Members
Namespace: DotNext.Metaprogramming
Assembly: DotNext.Metaprogramming.dll
Syntax
public sealed class TryBuilder : ExpressionBuilder<TryExpression>, IExpressionBuilder<TryExpression>
Methods
| Improve this Doc View SourceCatch(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, TryBuilder.Filter, TryBuilder.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, TryBuilder.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<TException>(TryBuilder.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. |
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(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 |
|