Struct DatabaseResult
- Namespace
- FishMMO.Database
- Assembly
- FishMMO-DB.dll
Non-generic version of DatabaseResult for operations that don't return data.
public readonly struct DatabaseResult
- Inherited Members
Properties
ErrorCode
Gets the error code if the operation failed. Null when IsSuccess is true; non-null when IsSuccess is false.
public string? ErrorCode { get; }
Property Value
ErrorMessage
Gets the safe error message suitable for client communication. Null when IsSuccess is true; non-null when IsSuccess is false.
public string? ErrorMessage { get; }
Property Value
IsSuccess
Gets a value indicating whether the operation succeeded.
public bool IsSuccess { get; }
Property Value
IsTransient
Gets a value indicating whether the error is transient and the operation can be retried.
public bool IsTransient { get; }
Property Value
Methods
Deconstruct(out bool, out string?, out string?, out bool)
Deconstructs the result into its components for pattern matching.
public void Deconstruct(out bool isSuccess, out string? errorCode, out string? errorMessage, out bool isTransient)
Parameters
isSuccessboolWhether the operation succeeded.
errorCodestringThe error code (null if succeeded).
errorMessagestringThe error message (null if succeeded).
isTransientboolWhether the error is transient.
Failure(string?, string?, bool)
Creates a failed result with error information.
public static DatabaseResult Failure(string? errorCode, string? errorMessage, bool isTransient = false)
Parameters
errorCodestringThe error code for categorization. Defaults to
DB_ERRORif null.errorMessagestringSafe error message for client communication. Defaults to a generic message if null.
isTransientboolWhether the error is transient and retryable.
Returns
- DatabaseResult
A failed DatabaseResult containing error information.
FromException(DatabaseException)
Creates a failed result from a DatabaseException.
public static DatabaseResult FromException(DatabaseException exception)
Parameters
exceptionDatabaseExceptionThe database exception to convert.
Returns
- DatabaseResult
A failed DatabaseResult containing exception information.
Success()
Creates a successful result.
public static DatabaseResult Success()
Returns
- DatabaseResult
A successful DatabaseResult.
ToString()
Returns a string representation of the result.
public override string ToString()
Returns
- string
Formatted string with success/failure status.