Table of Contents

Class DatabaseException

Namespace
FishMMO.Database.Exceptions
Assembly
FishMMO-DB.dll

Base exception for all database-related errors in the FishMMO database layer. Provides safe error messages for client communication while preserving detailed information for logging. Follows Open/Closed Principle: extensible through inheritance for specific error types.

public class DatabaseException : Exception, ISerializable
Inheritance
DatabaseException
Implements
Derived
Inherited Members

Constructors

DatabaseException(string, Exception, string, bool)

Initializes a new instance of the DatabaseException class with an inner exception.

public DatabaseException(string safeMessage, Exception innerException, string errorCode = "DB_ERROR", bool isTransient = false)

Parameters

safeMessage string

Safe error message for client communication.

innerException Exception

The exception that caused this exception.

errorCode string

Error code for categorization.

isTransient bool

Whether the error is transient and retryable.

DatabaseException(string, string, bool)

Initializes a new instance of the DatabaseException class.

public DatabaseException(string safeMessage, string errorCode = "DB_ERROR", bool isTransient = false)

Parameters

safeMessage string

Safe error message for client communication.

errorCode string

Error code for categorization.

isTransient bool

Whether the error is transient and retryable.

DatabaseException(string, string, string, bool)

Initializes a new instance of the DatabaseException class with detailed internal message.

public DatabaseException(string safeMessage, string detailedMessage, string errorCode = "DB_ERROR", bool isTransient = false)

Parameters

safeMessage string

Safe error message for client communication.

detailedMessage string

Detailed message for logging (may contain sensitive data).

errorCode string

Error code for categorization.

isTransient bool

Whether the error is transient and retryable.

Properties

ErrorCode

Gets the error code for categorizing the exception type. Used for client-side error handling and logging aggregation.

public string ErrorCode { get; protected set; }

Property Value

string

IsTransient

Gets a value indicating whether this error is transient and may succeed on retry.

public bool IsTransient { get; protected set; }

Property Value

bool

SafeMessage

Gets the safe error message suitable for displaying to end users or clients. Does not contain sensitive information like SQL queries, connection strings, or internal details.

public string SafeMessage { get; protected set; }

Property Value

string

Methods

ToString()

Returns a string representation of the exception including error code.

public override string ToString()

Returns

string

Formatted string with error code and message.