Skip to content

fix: commit #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 16, 2024
Merged

fix: commit #2

merged 7 commits into from
Oct 16, 2024

Conversation

walmir-silva
Copy link
Contributor

No description provided.

- Added base folder structure
- Configured Composer with dependencies and autoload settings
- Included development tools: PHPUnit, PHPStan, PHP CS Fixer, and PHP CodeSniffer
- Added Docker setup with docker-compose.yml
- Provided example environment configuration (.env.example)
- Created `AbstractException` as the base exception class
- Added `AuthenticationException` and `AuthorizationException` under `Auth`
- Added `CacheException` under `Cache`
- Added `ConfigurationException` under `Config`
- Added `ContainerException` under `Container`
- Added `DatabaseException` under `Database`
- Added `EventException` under `Event`
- Added `ExternalServiceException` under `ExternalService`
- Added `FileException` under `File`
- Added `InputException` under `Input`
- Added `LocalizationException` under `Localization`
- Added `MiddlewareException` under `Middleware`
- Added `NetworkException` and `HttpException` under `Network`
- Added `QueueException` under `Queue`
- Added `RoutingException` under `Routing`
- Added `RuntimeException` under `Runtime`
- Added `SecurityException` and `EncryptionException` under `Security`
- Added `SessionException` under `Session`
- Added `SystemException` under `System`
- Added `TemplateException` under `Template`
- Added `ValidationException` and `RuleViolationException` under `Validation`
- Added PHPUnit test classes for each exception class under `tests` directory
- Created directory structure mirroring the source code for proper organization of tests
- **Added numeric error code constants** to all exception classes in `src/` directory.
  - Each exception class now defines private constants for error codes.
  - Factory methods updated to use these constants when creating `ExceptionMessage` instances.
- **Modified `ExceptionMessage` class** to accept `int $code` as the first parameter.
  - Updated constructor signature to `public function __construct(int $code, string $errorCode, string $message)`.
  - Ensured compatibility across all usages.
- **Updated `AbstractException` class**:
  - Constructor now sets the numeric code from `ExceptionMessage` using `$errorMessage->getCode()`.
  - Maintains error code string and context.
- **Refactored exception tests in `tests/` directory**:
  - Updated `assertExceptionStructure` method in `AbstractExceptionTest` to include assertion for numeric error code.
  - All exception test classes now pass the expected numeric code to `assertExceptionStructure`.
  - Ensured that all tests reflect the changes in the exception classes and pass successfully.
- **Consistent Error Code Ranges**:
  - Established a consistent error code range for each exception type as per the error code range table.
  - This enhances error categorization and future maintainability.

**Summary:**

This commit refactors the exception handling mechanism by introducing numeric error code constants across all exception classes and their corresponding tests. This change enhances the clarity and maintainability of the codebase by:

- Providing a standardized way to identify exceptions through numeric codes.
- Improving error categorization according to the defined error code ranges.
- Ensuring consistency between the exception classes and their tests.
- Facilitating better integration with logging and error handling systems that utilize numeric error codes.
…component

- Added README.md (English version) with detailed instructions for using the Exception component
- Added README.pt-br.md (Portuguese version) with equivalent content for Brazilian developers
@walmir-silva walmir-silva merged commit 0779709 into main Oct 16, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant