Table of Contents

Class Try

Namespace
BotManager.Runtime.Expressions
Assembly
BotManager.Runtime.dll

Trys to execute the Expression and handles any exceptions. If an exception is throw while executing Expression, it will write the Exception to 'exception' in the current RuntimeContext and then run the Catch expression.

Returns the value of the executed branch.

This json example returns 10:
{ "$Try": { "Expression": 10, "Catch": -10 } }
public sealed class Try : IExpression
Inheritance
Try
Implements
Inherited Members

Constructors

Try()

public Try()

Properties

Catch

Gets and sets the expression to execute if Expression failed.

public IExpression? Catch { get; set; }

Property Value

IExpression

Expression

Gets and sets the expression to try.

public IExpression? Expression { get; set; }

Property Value

IExpression

Methods

ExecuteAsync(RuntimeContext, Type?)

Executes the expression in the given RuntimeContext. Please do not use this method to run an expression. Use ExecuteAsync(IExpression?) instead.

public Task<object?> ExecuteAsync(RuntimeContext context, Type? returnType)

Parameters

context RuntimeContext

The current runtime context.

returnType Type

The expected return type. Use typeof(object) for a generic result. Use null if you don't need the return value.

Returns

Task<object>

Returns the result of the expression.