Struct AddressableResult
Represents the outcome of a void Addressables operation - one that loads, releases, unloads, or downloads content without returning a usable asset value. Carries either a success indicator or a structured error comprising an ErrorCode, human-readable ErrorMessage, and optional Exception.
Inherited Members
Namespace: Scylla.Core.Util.Addressables
Assembly: ScyllaCore.dll
Syntax
public readonly struct AddressableResult
Remarks
AddressableResult is part of the result-pattern API surface of
ScyllaAddressables. Methods that return this type never throw
AddressableException under normal failure conditions - all
failure information is captured within the struct. This makes it safe to call
them without a try/catch block:
var result = await ScyllaAddressables.DownloadResultAsync("my/bundle");
if (result.IsFailure)
{
Debug.LogError($"Download failed: {result.ErrorMessage} ({result.ErrorCode})");
}
For operations that return an asset value, use AddressableResult<T> instead.
Instances are created exclusively via the factory methods Success(), Failure(AddressableErrorCode, string, Exception), and FromException(AddressableException). The constructor is private.
Properties
ErrorCode
Gets the structured error code that categorizes the failure, or
Unknown when IsSuccess is
true. Use this to implement targeted retry or fallback logic without
inspecting the message string.
Declaration
public AddressableErrorCode ErrorCode { get; }
Property Value
| Type | Description |
|---|---|
| AddressableErrorCode |
ErrorMessage
Gets a human-readable description of why the operation failed, or null
when IsSuccess is true. This is suitable for display in
debug UIs or log output but should not be parsed programmatically - use
ErrorCode for branching logic.
Declaration
public string ErrorMessage { get; }
Property Value
| Type | Description |
|---|---|
| string |
Exception
Gets the exception that caused the failure if one was available at the point of
capture, or null when the failure arose from a non-exception code path
(e.g., an address validation rejection) or when the operation succeeded.
When non-null, this is typically an AddressableException wrapping
a Unity AsyncOperationHandle exception.
Declaration
public Exception Exception { get; }
Property Value
| Type | Description |
|---|---|
| Exception |
IsFailure
Gets a value indicating whether the Addressables operation encountered an error.
This is the logical inverse of IsSuccess. When true, inspect
ErrorCode for the structured failure category and
ErrorMessage for a human-readable description.
Declaration
public bool IsFailure { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsSuccess
Gets a value indicating whether the Addressables operation completed without error.
When true, ErrorMessage, ErrorCode, and
Exception carry no meaningful failure information.
Declaration
public bool IsSuccess { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
Failure(AddressableErrorCode, string, Exception)
Creates an AddressableResult that represents a failed operation
with the given error code. The ErrorMessage is taken from the
explicit errorMessage argument when provided; otherwise a
default message is generated from errorCode.
Declaration
public static AddressableResult Failure(AddressableErrorCode errorCode, string errorMessage = null, Exception exception = null)
Parameters
| Type | Name | Description |
|---|---|---|
| AddressableErrorCode | errorCode | The AddressableErrorCode that categorizes the failure. Must not be called with a sentinel value unless the failure genuinely cannot be classified. |
| string | errorMessage | An optional human-readable description of the failure. When |
| Exception | exception | The exception that caused the failure, if available. May be |
Returns
| Type | Description |
|---|---|
| AddressableResult | A new AddressableResult with IsSuccess set to
|
FromException(AddressableException)
Creates a failed AddressableResult from an existing
AddressableException, preserving its ErrorCode,
Message, and the exception itself as
Exception. When exception is null, the
result uses Unknown and a generic message.
Declaration
public static AddressableResult FromException(AddressableException exception)
Parameters
| Type | Name | Description |
|---|---|---|
| AddressableException | exception | The AddressableException to convert into a result. May be
|
Returns
| Type | Description |
|---|---|
| AddressableResult | A new AddressableResult with IsSuccess set to
|
Success()
Creates an AddressableResult that represents a successful operation.
IsSuccess will be true; ErrorCode is set to
Unknown as a neutral sentinel, and
ErrorMessage and Exception are both null.
Declaration
public static AddressableResult Success()
Returns
| Type | Description |
|---|---|
| AddressableResult | A new AddressableResult representing a successful outcome. |