Download the PHP package kariricode/exception without Composer
On this page you can find all versions of the php package kariricode/exception. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kariricode/exception
More information about kariricode/exception
Files in kariricode/exception
Package exception
Short Description KaririCode Exception provides a robust and modular exception handling system for the KaririCode Framework, enabling seamless error management across various application domains.
License MIT
Homepage https://kariricode.org
Informations about the package exception
KaririCode Framework: Exception Component
A comprehensive and flexible exception handling component for PHP, part of the KaririCode Framework. It provides a structured approach to error management, enhancing the robustness and maintainability of your applications.
Table of Contents
- Features
- Installation
- Usage
- Basic Usage
- Advanced Usage
- Error Code Range Table
- Available Exception Types
- Integration with Other KaririCode Components
- Development and Testing
- License
- Support and Community
Features
- Hierarchical exception structure for better error categorization
- Context-aware exceptions for richer error information
- Static factory methods for easy exception creation
- Integration with KaririCode's error handling and logging systems
- Extensible architecture allowing custom exception types
- Comprehensive set of pre-defined exception types for common scenarios
Installation
You can install the Exception component via Composer:
Requirements
- PHP 8.1 or higher
- Composer
Usage
Basic Usage
Using Pre-defined Exceptions in Your Code
The KaririCode Exception component provides a variety of pre-defined exceptions that you can use to handle common error scenarios in a professional and structured manner. Below is an example of how to use these exceptions in an object-oriented context.
Advanced Usage
Create custom exceptions by extending the base classes:
Using custom exceptions in your application:
Error Code Range Table
Here is a proposed table for the error code ranges. Each range is assigned to a group of related errors, allowing better organization and identification of errors in the system.
Error Code Range Table
Range | Error Group | Description |
---|---|---|
1000 - 1099 | Authentication Errors | Errors related to authentication and login |
1100 - 1199 | Authorization Errors | Errors related to permissions and roles |
1200 - 1299 | Cache Errors | Errors related to cache operations |
1300 - 1399 | Configuration Errors | Errors related to configuration settings |
1400 - 1499 | Container Errors | Errors related to dependency injection and services |
1500 - 1599 | Database Errors | Errors related to database connections, queries, etc. |
1600 - 1699 | Event Errors | Errors related to event handling and dispatching |
1700 - 1799 | External Service Errors | Errors related to external API calls and services |
1800 - 1899 | File System Errors | Errors related to file operations (reading, writing) |
1900 - 1999 | Input/Validation Errors | Errors related to invalid input or validation |
2000 - 2099 | Localization Errors | Errors related to localization and translations |
2100 - 2199 | Middleware Errors | Errors related to middleware processing |
2200 - 2299 | Network Errors | Errors related to network operations |
2300 - 2399 | Queue Errors | Errors related to queuing systems |
2400 - 2499 | Routing Errors | Errors related to routing and HTTP methods |
2500 - 2599 | Runtime Errors | General runtime errors |
2600 - 2699 | Encryption Errors | Errors related to encryption and decryption |
2700 - 2799 | Security Errors | Errors related to security, access control, etc. |
2800 - 2899 | Session Errors | Errors related to session handling |
2900 - 2999 | System Errors | Errors related to system resources and environment |
3000 - 3099 | Template Errors | Errors related to template rendering and loading |
3100 - 3199 | Validation Errors | Errors related to data validation |
4000 - 4099 | Business Logic Errors | Custom errors for business logic violations |
Explanation of Each Range:
-
1000 - 1099: Authentication Errors
- Errors related to user authentication, such as invalid credentials, locked accounts, or missing two-factor authentication.
-
1100 - 1199: Authorization Errors
- Errors related to insufficient permissions or missing roles during authorization processes.
-
... (Same as previous ranges)
-
3100 - 3199: Validation Errors
- Errors related to data validation.
- 4000 - 4099: Business Logic Errors
- Custom error codes for business logic violations specific to your application.
This structure allows you to easily categorize and expand error codes in the future, keeping the error-handling system organized.
Available Exception Types
Each exception type is designed to handle specific error scenarios. For detailed information on each exception type, please refer to the documentation.
Integration with Other KaririCode Components
The Exception component is designed to work seamlessly with other KaririCode components:
- KaririCode\Logger: For advanced error logging and reporting.
- KaririCode\Http: For handling HTTP-related exceptions.
- KaririCode\Database: For database-specific exceptions.
Development and Testing
For development and testing purposes, this package uses Docker and Docker Compose to ensure consistency across different environments. A Makefile is provided for convenience.
Prerequisites
- Docker
- Docker Compose
- Make (optional, but recommended for easier command execution)
Development Setup
-
Clone the repository:
-
Set up the environment:
-
Start the Docker containers:
- Install dependencies:
Available Make Commands
make up
: Start all services in the backgroundmake down
: Stop and remove all containersmake build
: Build Docker imagesmake shell
: Access the PHP container shellmake test
: Run testsmake coverage
: Run test coverage with visual formattingmake cs-fix
: Run PHP CS Fixer to fix code stylemake quality
: Run all quality commands (cs-check, test, security-check)
For a full list of available commands, run:
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support and Community
- Documentation: https://kariricode.org/docs/exception
- Issue Tracker: GitHub Issues
- Community: KaririCode Club Community
Built with ❤️ by the KaririCode team. Empowering developers to handle errors effectively and build more resilient PHP applications.