Show / Hide Table of Contents

Class TryBuilder

Represents structured exception handling statement.

Inheritance
object
ExpressionBuilder<TryExpression>
TryBuilder
Implements
ISupplier<TryExpression>
IFunctional<Func<TryExpression>>
Inherited Members
ExpressionBuilder<TryExpression>.OfType(Type)
ExpressionBuilder<TryExpression>.OfType<T>()
ExpressionBuilder<TryExpression>.End()
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DotNext.Metaprogramming
Assembly: DotNext.Metaprogramming.dll
Syntax
public sealed class TryBuilder : ExpressionBuilder<TryExpression>, ISupplier<TryExpression>, IFunctional<Func<TryExpression>>

Methods

| Edit this page View Source

Catch(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.

| Edit this page View Source

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

this builder.

| Edit this page View Source

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

this builder.

| Edit this page View Source

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.

| Edit this page View Source

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

this builder.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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

this builder.

Type Parameters
Name Description
TException

Expected exception.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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

this builder.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Edit this page View Source

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

this builder.

| Edit this page View Source

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

this builder.

Exceptions
Type Condition
InvalidOperationException

Attempts to call this method out of lexical scope.

| Edit this page View Source

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

this builder.

Implements

ISupplier<TResult>
IFunctional<TDelegate>

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.GetUserData<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
ExpressionBuilder.Const<T>(T)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan, CancellationToken)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)

See Also

try-catch statement
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾