Luminova Framework

PHP Luminova: Exceptions and Error Codes

Last updated: 2025-08-27 18:19:45

Explore Comprehensive Documentation on Luminova Exception and Error Handling: Detailed Error Types and Codes for Enhanced Code Quality.

This guide explains Luminova’s exception codes, their severity levels, and how to use them effectively.All error codes are now defined as constants in the Luminova\Exceptions\Code class. These codes represent different categories of errors, including:

  • PDO SQLSTATE errors
  • MySQL errors
  • PostgreSQL errors
  • Custom application errors

Using Error Codes

You can pass an error code when throwing exceptions.

use Luminova\Exceptions\Code;
use Luminova\Exceptions\RuntimeException;

throw new RuntimeException('Error message', Code::BAD_METHOD_CALL);

getName

Get a Human-Friendly Error Name

Translate internal error codes into descriptive names that are easier to understand.

use Luminova\Exceptions\Code;

echo Code::getName(Code::INPUT_VALIDATION_ERROR);

// Output: Validation Error

You can also ask for a longer description:

use Luminova\Exceptions\Code;

echo Code::getName(Code::INPUT_VALIDATION_ERROR, true);
// Output: Input validation failed

This is especially helpful when displaying error messages to developers or when logging meaningful details.


has

Check if a given error code is defined in the Code class.

use Luminova\Exceptions\Code;

Code::has(Code::ERROR);

Constants

All error codes are centralized in the Code class.Reference them directly whenever you need to identify or classify an error:

Luminova\Exceptions\Code::ERROR

PHP Error Codes

These constants map directly to standard PHP error types. You can use them for handling, logging, or categorizing errors in your application.

ConstantValueDescription
ERRORE_ERRORFatal run-time errors.
PARSE_ERRORE_PARSECompile-time parse errors.
CORE_ERRORE_CORE_ERRORFatal errors that occur during PHP's initial startup.
COMPILE_ERRORE_COMPILE_ERRORFatal compile-time errors.
WARNINGE_WARNINGRun-time warnings (non-fatal errors).
CORE_WARNINGE_CORE_WARNINGWarnings that occur during PHP's initial startup.
COMPILE_WARNINGE_COMPILE_WARNINGCompile-time warnings.
USER_WARNINGE_USER_WARNINGUser-generated warnings.
NOTICEE_NOTICERun-time notices (non-critical errors).
USER_NOTICEE_USER_NOTICEUser-generated notices.
STRICT_NOTICEE_STRICTSuggestions for code improvements.
USER_ERRORE_USER_ERRORUser-generated fatal errors.
RECOVERABLE_ERRORE_RECOVERABLE_ERRORErrors that can be caught by a catch block.
DEPRECATEDE_DEPRECATEDNotices of deprecated features.
USER_DEPRECATEDE_USER_DEPRECATEDUser-generated notices of deprecated features.

Database Error Codes

PDO SQLSTATE Codes

These constants map to SQLSTATE error codes used by PDO. They help you detect and handle database connection problems or SQL execution errors more precisely.

ConstantValueDescription
UNABLE_TO_CONNECT08001Unable to connect to the database.
CONNECTION_DENIED08004Connection denied due to invalid credentials.
INTEGRITY_CONSTRAINT_VIOLATION23000Integrity constraint violation, such as foreign key issues.
SQL_SYNTAX_ERROR_OR_ACCESS_VIOLATION42000SQL syntax error or access violation.

MySQL Error Codes

These constants correspond to common MySQL error codes. They allow you to handle database issues specific to MySQL, such as duplicate entries, missing tables, or connection problems.

ConstantValueDescription
ACCESS_DENIED_FOR_USER1044Access denied for the user.
ACCESS_DENIED_INVALID_PASSWORD1045Access denied due to invalid password.
UNKNOWN_DATABASE1049Unknown database specified in the connection.
SYNTAX_ERROR_IN_SQL_STATEMENT1064Syntax error in SQL statement.
TABLE_DOES_NOT_EXIST1146The specified table does not exist.

PostgreSQL Error Codes

These constants represent PostgreSQL-specific error codes. They are useful when handling authentication errors, missing databases, or other PostgreSQL issues.

ConstantValueDescription
INVALID_AUTHORIZATION_SPECIFICATION28000The authorization specification is invalid.
INVALID_CATALOG_NAME3D000The specified database name is invalid.

SQLite Error Codes

These constants represent SQLite-specific error codes. They are useful when handling storage, locking, or database file issues.

ConstantValueDescription
DATABASE_IS_FULL5The database has run out of storage space.
DATABASE_LOCKED6The database file is locked.

Custom Luminova Error Codes

These constants are unique to the Luminova framework. They provide a standardized way to represent application-specific errors that go beyond PHP or database engine codes. You can use them to handle issues such as database failures, validation problems, or other framework-level exceptions in a consistent way.

ConstantValueDescription
DATABASE_ERROR1500General database error.
FAILED_ALL_CONNECTION_ATTEMPTS1503Failed all attempts to connect to the database.
CONNECTION_LIMIT_EXCEEDED1509Connection limit exceeded.
INVALID_DATABASE_DRIVER1406Invalid database driver specified.
DATABASE_DRIVER_NOT_AVAILABLE1501Database driver not available.
DATABASE_TRANSACTION_READONLY_FAILED1417Failed to execute a read-only transaction.
DATABASE_TRANSACTION_FAILED1420Database transaction failed.
TRANSACTION_SAVEPOINT_FAILED1418Failed to create a transaction savepoint.
FAILED_TO_ROLLBACK_TRANSACTION1419Failed to rollback the transaction.
NO_STATEMENT_TO_EXECUTE1499No SQL statement to execute.
VALUE_FORBIDDEN1403Forbidden value encountered.
INVALID_ARGUMENTS1001Invalid arguments provided to a function.
INVALID1002General invalid error.
RUNTIME_ERROR5001General runtime error.
CLASS_NOT_FOUND5011Class not found during execution.
STORAGE_ERROR5079General storage error.
VIEW_NOT_FOUND404The requested view could not be found.
INPUT_VALIDATION_ERROR4070Input validation error occurred.
ROUTING_ERROR4161Error in routing the request.
NOT_FOUND4040Requested resource not found.
BAD_METHOD_CALL4051Method call failed due to invalid parameters.
CACHE_ERROR5071Error related to caching.
FILESYSTEM_ERROR6204Filesystem error encountered.
COOKIE_ERROR4961Error related to cookies.
DATETIME_ERROR2306Error in date/time operations.
CRYPTOGRAPHY_ERROR3423Error related to cryptographic operations.
WRITE_PERMISSION_DENIED6205Denied write permission.
READ_PERMISSION_DENIED6206Denied read permission.
READ_WRITE_PERMISSION_DENIED6209Denied read/write permission.
CREATE_DIR_FAILED6207Failed to create a directory.
SET_PERMISSION_FAILED6208Failed to set permissions on a file/directory.
JSON_ERROR4180JSON encoding/decoding error.
SECURITY_ISSUE4973Security issue detected.
MAILER_ERROR449Error related to mailer functionality.
INVALID_CONTROLLER1003Invalid controller specified.
INVALID_METHOD4052Invalid method specified.
INVALID_REQUEST_METHOD4053Invalid request method used.
NOT_ALLOWED4061Operation not allowed.
NOT_SUPPORTED4062Operation not supported.
LOGIC_ERROR4229Logical error in the application.
UNDEFINED8790Undefined error occurred.
HTTP_CLIENT_ERROR4974Client error occurred during an HTTP request.
HTTP_CONNECTION_ERROR4975Connection error during HTTP request.
HTTP_REQUEST_ERROR4976Error during HTTP request processing.
HTTP_SERVER_ERROR4977Server error occurred while processing HTTP request.
HTTP_RESPONSE_ERROR4978HTTP response error occurred while processing request.