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.
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
Expression
Gets and sets the expression to try.
public IExpression? Expression { get; set; }
Property Value
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
contextRuntimeContextThe current runtime context.
returnTypeTypeThe expected return type. Use
typeof(object)for a generic result. Usenullif you don't need the return value.