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
safeMessagestringSafe error message for client communication.
innerExceptionExceptionThe exception that caused this exception.
errorCodestringError code for categorization.
isTransientboolWhether 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
safeMessagestringSafe error message for client communication.
errorCodestringError code for categorization.
isTransientboolWhether 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
safeMessagestringSafe error message for client communication.
detailedMessagestringDetailed message for logging (may contain sensitive data).
errorCodestringError code for categorization.
isTransientboolWhether 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
IsTransient
Gets a value indicating whether this error is transient and may succeed on retry.
public bool IsTransient { get; protected set; }
Property Value
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
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.