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 Type | Available | 
|---|---|
| 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 fromException) if the error originated from logic- Other exceptions for errors originated from LOC runtime or SDK, etc.
 
Properties
RailwayError
| Property | Type | Description | 
|---|---|---|
Name | string | Error name | 
Message | string | Error message | 
StackTrace | string | Error stack trace message | 
LogicIdentity | VersionedIdentity? | Logic permanent ID where error originated | 
Exception
Refer to:
Exception
Sub Class Reference
VersionedIdentity
| Property | Type | Description | 
|---|---|---|
PermanentIdentity | Guid | Permanent identity (PID) | 
Revision | int | Revision 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
RailwayErrorby LOC runtime.