Result<T>
The Result type is meant to provide more safety to fallible asynchronous operations.
All asynchronous operations in the Saga Unity plugin return either Result or Result<T> wrapping
type T.
Result comes with two guarantees:
If Result.IsSuccess == true, then Result.Data != null.
If Result.IsSuccess == false, then Result.Error != null.
The goal of this type is to remind the developer to check and make sure that the operation succeeded in a graceful manner, without requiring a clunky try/catch statement.
Error Handling
Result.IsSuccess should always be handled before accessing Result.Data. In
the event of an error, the Result.Error object may contain both Result.Error.StatusCode
and Result.Error.Message. The StatusCode can be compared to the SagaResponseCode
enum:
if (result.Error.StatusCode == (int) SagaResponseCode.Unauthorized) {
... do something ...
}