Skip to main content

Logic Error - C Sharp

If an unhandled error had been thrown in the task, an error object would be passed to the logic and all subsequential ones. The object is an instance of Exception in C#.

Logic TypeAvailable
Generic logic✅ (HandleError only)
Aggregator logic✅ (HandleError only)

Import and Usage

The handleError function in a logic receives a error argument by default:

public static class Logic
{

public static async Task Run(Context ctx)
{

}

public static async Task HandleError(Context ctx, Exception error)
{
// error may contain railway error
}
}

Class Reference

Type

  • RailwayError (extended from Exception) if the error originated from logic
  • Other exceptions for errors originated from LOC runtime or SDK, etc.

Properties

  • RailwayError
PropertyTypeDescription
NamestringError name
MessagestringError message
StackTracestringError stack trace message
LogicIdentityVersionedIdentity?Logic permanent ID where error originated

Exception

Refer to: Exception

Sub Class Reference

VersionedIdentity

PropertyTypeDescription
PermanentIdentityGuidPermanent identity (PID)
RevisionintRevision number

Examples

Read Exception

HandleError()
// if error is a railway error
if (error is RailwayError railwayError)
{
string errorPid = railwayError.LogicIdentity.PermanentIdentity.ToString();
string errorFullMessage = railwayError.ToString();
}

// for all exception types
string errorMessage = error.Message;
string errorStack = error.StackTrace;

Throw Exception

throw new Exception("oh no, not again.");

The error will be packaged as RailwayError by LOC runtime.