Table of Contents

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

string

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

string

IsSuccess

Gets a value indicating whether the operation succeeded.

public bool IsSuccess { get; }

Property Value

bool

IsTransient

Gets a value indicating whether the error is transient and the operation can be retried.

public bool IsTransient { get; }

Property Value

bool

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

isSuccess bool

Whether the operation succeeded.

errorCode string

The error code (null if succeeded).

errorMessage string

The error message (null if succeeded).

isTransient bool

Whether 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

errorCode string

The error code for categorization. Defaults to DB_ERROR if null.

errorMessage string

Safe error message for client communication. Defaults to a generic message if null.

isTransient bool

Whether 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

exception DatabaseException

The 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.