From 0df4ef5d370bd2897651bf9ac1b664ca420f2112 Mon Sep 17 00:00:00 2001 From: Jagepard Date: Fri, 27 Jun 2025 15:41:25 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D0=BB=20=D0=BB?= =?UTF-8?q?=D0=B8=D1=88=D0=BD=D0=B5=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs.md | 233 +++++++++++---------------------- src/ConfigurationException.php | 12 -- src/DBException.php | 17 --- src/DatabaseException.php | 12 -- src/EnvironmentException.php | 12 -- src/ExceptionInterface.php | 21 +-- src/LogicException.php | 17 +-- src/MiddlewareException.php | 12 +- src/NotFoundException.php | 7 + src/RequestException.php | 12 -- src/RouterException.php | 47 ++----- src/RudraException.php | 12 +- 12 files changed, 104 insertions(+), 310 deletions(-) delete mode 100644 src/ConfigurationException.php delete mode 100755 src/DBException.php delete mode 100644 src/DatabaseException.php delete mode 100644 src/EnvironmentException.php delete mode 100644 src/RequestException.php diff --git a/docs.md b/docs.md index 996a729..13ef819 100644 --- a/docs.md +++ b/docs.md @@ -1,194 +1,121 @@ ## Table of contents -- [Rudra\Exceptions\ConfigurationException](#rudra_exceptions_configurationexception) -- [Rudra\Exceptions\DBException](#rudra_exceptions_dbexception) -- [Rudra\Exceptions\DatabaseException](#rudra_exceptions_databaseexception) -- [Rudra\Exceptions\EnvironmentException](#rudra_exceptions_environmentexception) +- [Rudra\Exceptions\ExceptionInterface](#rudra_exceptions_exceptioninterface) - [Rudra\Exceptions\LogicException](#rudra_exceptions_logicexception) +- [Rudra\Exceptions\MiddlewareException](#rudra_exceptions_middlewareexception) - [Rudra\Exceptions\NotFoundException](#rudra_exceptions_notfoundexception) -- [Rudra\Exceptions\RequestException](#rudra_exceptions_requestexception) - [Rudra\Exceptions\RouterException](#rudra_exceptions_routerexception) - [Rudra\Exceptions\RudraException](#rudra_exceptions_rudraexception) +- [Rudra\Exceptions\RuntimeException](#rudra_exceptions_runtimeexception)
- + -### Class: Rudra\Exceptions\ConfigurationException -##### extends [Rudra\Exceptions\RudraException](#rudra_exceptions_rudraexception) -##### implements [Stringable](#stringable) -##### implements [Throwable](#throwable) +### Class: Rudra\Exceptions\ExceptionInterface | Visibility | Function | |:-----------|:---------| -|public|__construct( string $message int $code ?Throwable $previous )
| -|public|__wakeup()
| -|final public|getMessage(): string
| -|final public|getCode()
| -|final public|getFile(): string
| -|final public|getLine(): int
| -|final public|getTrace(): array
| -|final public|getPrevious(): ?Throwable
| -|final public|getTraceAsString(): string
| -|public|__toString(): string
| - - - - -### Class: Rudra\Exceptions\DBException -##### extends [Rudra\Exceptions\RudraException](#rudra_exceptions_rudraexception) -##### implements [Stringable](#stringable) -##### implements [Throwable](#throwable) -| Visibility | Function | -|:-----------|:---------| -|public|__construct( string $message int $code ?Throwable $previous )
| -|public|__wakeup()
| -|final public|getMessage(): string
| -|final public|getCode()
| -|final public|getFile(): string
| -|final public|getLine(): int
| -|final public|getTrace(): array
| -|final public|getPrevious(): ?Throwable
| -|final public|getTraceAsString(): string
| -|public|__toString(): string
| - - - - -### Class: Rudra\Exceptions\DatabaseException -##### extends [Rudra\Exceptions\RudraException](#rudra_exceptions_rudraexception) -##### implements [Stringable](#stringable) -##### implements [Throwable](#throwable) -| Visibility | Function | -|:-----------|:---------| -|public|__construct( string $message int $code ?Throwable $previous )
| -|public|__wakeup()
| -|final public|getMessage(): string
| -|final public|getCode()
| -|final public|getFile(): string
| -|final public|getLine(): int
| -|final public|getTrace(): array
| -|final public|getPrevious(): ?Throwable
| -|final public|getTraceAsString(): string
| -|public|__toString(): string
| - - - - -### Class: Rudra\Exceptions\EnvironmentException -##### extends [Rudra\Exceptions\RudraException](#rudra_exceptions_rudraexception) -##### implements [Stringable](#stringable) -##### implements [Throwable](#throwable) -| Visibility | Function | -|:-----------|:---------| -|public|__construct( string $message int $code ?Throwable $previous )
| -|public|__wakeup()
| -|final public|getMessage(): string
| -|final public|getCode()
| -|final public|getFile(): string
| -|final public|getLine(): int
| -|final public|getTrace(): array
| -|final public|getPrevious(): ?Throwable
| -|final public|getTraceAsString(): string
| -|public|__toString(): string
| ### Class: Rudra\Exceptions\LogicException -##### extends [Rudra\Exceptions\RudraException](#rudra_exceptions_rudraexception) -##### implements [Stringable](#stringable) -##### implements [Throwable](#throwable) | Visibility | Function | |:-----------|:---------| -|public|__construct( string $message int $code ?Throwable $previous )
| -|public|__wakeup()
| -|final public|getMessage(): string
| -|final public|getCode()
| -|final public|getFile(): string
| -|final public|getLine(): int
| -|final public|getTrace(): array
| -|final public|getPrevious(): ?Throwable
| -|final public|getTraceAsString(): string
| -|public|__toString(): string
| +| public | `__construct(string $message, int $code, ?Throwable $previous)`
| +| public | `__wakeup()`
| +| final public | `getMessage(): string`
| +| final public | `getCode()`
| +| final public | `getFile(): string`
| +| final public | `getLine(): int`
| +| final public | `getTrace(): array`
| +| final public | `getPrevious(): ?Throwable`
| +| final public | `getTraceAsString(): string`
| +| public | `__toString(): string`
| - + -### Class: Rudra\Exceptions\NotFoundException -##### extends [Rudra\Exceptions\RudraException](#rudra_exceptions_rudraexception) -##### implements [Stringable](#stringable) -##### implements [Throwable](#throwable) +### Class: Rudra\Exceptions\MiddlewareException | Visibility | Function | |:-----------|:---------| -|public|__construct( string $message int $code ?Throwable $previous )
| -|public|__wakeup()
| -|final public|getMessage(): string
| -|final public|getCode()
| -|final public|getFile(): string
| -|final public|getLine(): int
| -|final public|getTrace(): array
| -|final public|getPrevious(): ?Throwable
| -|final public|getTraceAsString(): string
| -|public|__toString(): string
| - - - - -### Class: Rudra\Exceptions\RequestException -##### extends [Rudra\Exceptions\RudraException](#rudra_exceptions_rudraexception) -##### implements [Stringable](#stringable) -##### implements [Throwable](#throwable) +| public | `__construct(string $message, int $code, ?Throwable $previous)`
| +| public | `__wakeup()`
| +| final public | `getMessage(): string`
| +| final public | `getCode()`
| +| final public | `getFile(): string`
| +| final public | `getLine(): int`
| +| final public | `getTrace(): array`
| +| final public | `getPrevious(): ?Throwable`
| +| final public | `getTraceAsString(): string`
| +| public | `__toString(): string`
| + + + + +### Class: Rudra\Exceptions\NotFoundException | Visibility | Function | |:-----------|:---------| -|public|__construct( string $message int $code ?Throwable $previous )
| -|public|__wakeup()
| -|final public|getMessage(): string
| -|final public|getCode()
| -|final public|getFile(): string
| -|final public|getLine(): int
| -|final public|getTrace(): array
| -|final public|getPrevious(): ?Throwable
| -|final public|getTraceAsString(): string
| -|public|__toString(): string
| +| public | `__construct(string $message, int $code, ?Throwable $previous)`
| +| public | `__wakeup()`
| +| final public | `getMessage(): string`
| +| final public | `getCode()`
| +| final public | `getFile(): string`
| +| final public | `getLine(): int`
| +| final public | `getTrace(): array`
| +| final public | `getPrevious(): ?Throwable`
| +| final public | `getTraceAsString(): string`
| +| public | `__toString(): string`
| ### Class: Rudra\Exceptions\RouterException -##### extends [Rudra\Exceptions\RudraException](#rudra_exceptions_rudraexception) -##### implements [Stringable](#stringable) -##### implements [Throwable](#throwable) | Visibility | Function | |:-----------|:---------| -|public|__construct( $message $code ?Exception $previous )
| -|public|exception_handler( $exception )
| -|public|__wakeup()
| -|final public|getMessage(): string
| -|final public|getCode()
| -|final public|getFile(): string
| -|final public|getLine(): int
| -|final public|getTrace(): array
| -|final public|getPrevious(): ?Throwable
| -|final public|getTraceAsString(): string
| -|public|__toString(): string
| +| public | `__construct( $message, $code, ?Exception $previous)`
Constructs a new RouterException and sets a global exception handler.
The exception handler will catch all unhandled exceptions of this type
and redirect them using RedirectFacade to the appropriate error page/controller.
-------------------------
Конструктор RouterException устанавливает глобальный обработчик исключений.
Обработчик перехватывает все неперехваченные исключения этого типа
и вызывает RedirectFacade для перехода к странице/контроллеру ошибки. | +| public | `exception_handler(Exception $exception): void`
Custom exception handler triggered by this class.
Uses RedirectFacade to send an HTTP status code and then calls the error handler,
which is defined in the config under `http.errors`.
-------------------------
Собственный обработчик исключений, запускаемый этим классом.
Использует RedirectFacade для отправки HTTP-статуса и вызова обработчика ошибок,
указанного в конфигурации под ключом `http.errors`. | +| public | `__wakeup()`
| +| final public | `getMessage(): string`
| +| final public | `getCode()`
| +| final public | `getFile(): string`
| +| final public | `getLine(): int`
| +| final public | `getTrace(): array`
| +| final public | `getPrevious(): ?Throwable`
| +| final public | `getTraceAsString(): string`
| +| public | `__toString(): string`
| ### Class: Rudra\Exceptions\RudraException -##### extends [Exception](#exception) -##### implements [Throwable](#throwable) -##### implements [Stringable](#stringable) | Visibility | Function | |:-----------|:---------| -|public|__construct( string $message int $code ?Throwable $previous )
| -|public|__wakeup()
| -|final public|getMessage(): string
| -|final public|getCode()
| -|final public|getFile(): string
| -|final public|getLine(): int
| -|final public|getTrace(): array
| -|final public|getPrevious(): ?Throwable
| -|final public|getTraceAsString(): string
| -|public|__toString(): string
| +| public | `__construct(string $message, int $code, ?Throwable $previous)`
| +| public | `__wakeup()`
| +| final public | `getMessage(): string`
| +| final public | `getCode()`
| +| final public | `getFile(): string`
| +| final public | `getLine(): int`
| +| final public | `getTrace(): array`
| +| final public | `getPrevious(): ?Throwable`
| +| final public | `getTraceAsString(): string`
| +| public | `__toString(): string`
| + + + + +### Class: Rudra\Exceptions\RuntimeException +| Visibility | Function | +|:-----------|:---------| +| public | `__construct(string $message, int $code, ?Throwable $previous)`
| +| public | `__wakeup()`
| +| final public | `getMessage(): string`
| +| final public | `getCode()`
| +| final public | `getFile(): string`
| +| final public | `getLine(): int`
| +| final public | `getTrace(): array`
| +| final public | `getPrevious(): ?Throwable`
| +| final public | `getTraceAsString(): string`
| +| public | `__toString(): string`
|
###### created with [Rudra-Documentation-Collector](#https://github.com/Jagepard/Rudra-Documentation-Collector) diff --git a/src/ConfigurationException.php b/src/ConfigurationException.php deleted file mode 100644 index b0b8211..0000000 --- a/src/ConfigurationException.php +++ /dev/null @@ -1,12 +0,0 @@ - - * @license https://mit-license.org/ MIT - */ - -namespace Rudra\Exceptions; - -class ConfigurationException extends RudraException {} diff --git a/src/DBException.php b/src/DBException.php deleted file mode 100755 index b0fb3c4..0000000 --- a/src/DBException.php +++ /dev/null @@ -1,17 +0,0 @@ - - * @license https://mit-license.org/ MIT - */ - -namespace Rudra\Exceptions; - -/** - * @deprecated - */ -class DBException extends RudraException -{ -} diff --git a/src/DatabaseException.php b/src/DatabaseException.php deleted file mode 100644 index 351a500..0000000 --- a/src/DatabaseException.php +++ /dev/null @@ -1,12 +0,0 @@ - - * @license https://mit-license.org/ MIT - */ - -namespace Rudra\Exceptions; - -class DatabaseException extends RudraException {} diff --git a/src/EnvironmentException.php b/src/EnvironmentException.php deleted file mode 100644 index ab9fbe6..0000000 --- a/src/EnvironmentException.php +++ /dev/null @@ -1,12 +0,0 @@ - - * @license https://mit-license.org/ MIT - */ - -namespace Rudra\Exceptions; - -class EnvironmentException extends RudraException {} diff --git a/src/ExceptionInterface.php b/src/ExceptionInterface.php index 92c2af3..54f16a7 100644 --- a/src/ExceptionInterface.php +++ b/src/ExceptionInterface.php @@ -2,10 +2,9 @@ declare(strict_types=1); +namespace Rudra\Exceptions; + /** - * ExceptionInterface - * ================== - * * A marker interface used to tag all custom exceptions within the Rudra framework. * * This empty interface serves as a common base for grouping and filtering exceptions, @@ -24,14 +23,7 @@ * // Handle any Rudra-related exception uniformly * } * ``` - * - * @package Rudra\Exceptions - * @see \Rudra\Exceptions\MiddlewareException - * @see \Rudra\Exceptions\RouterException - * ---------------------------------------------------------------------------- - * ExceptionInterface - * ================== - * + * --------------------- * Маркерный интерфейс, используемый для группировки всех пользовательских исключений в фреймворке Rudra. * * Этот пустой интерфейс служит общей точкой отсчёта для группировки и фильтрации исключений, @@ -50,14 +42,7 @@ * // Единым образом обрабатываем все исключения из Rudra * } * ``` - * - * @package Rudra\Exceptions - * @see \Rudra\Exceptions\MiddlewareException - * @see \Rudra\Exceptions\RouterException */ - -namespace Rudra\Exceptions; - interface ExceptionInterface { // Пустой интерфейс — используется только как маркер для пользовательских исключений diff --git a/src/LogicException.php b/src/LogicException.php index 1521bad..55c2a88 100644 --- a/src/LogicException.php +++ b/src/LogicException.php @@ -2,10 +2,9 @@ declare(strict_types=1); +namespace Rudra\Exceptions; + /** - * LogicException - * ============== - * * An exception that indicates errors in the program logic. * This type of exception should lead directly to code fixes — these are not runtime issues, * but problems in implementation, configuration or incorrect use of the API. @@ -19,12 +18,7 @@ * throw new \Rudra\Exceptions\RouterException("503"); * } * ``` - * - * @package Rudra\Exceptions - * ---------------------------------------------------------------------------- - * LogicException - * ============== - * + * --------------------- * Исключение, указывающее на ошибки логики программы. * Такие ошибки должны приводить к исправлениям в коде — это не ошибки времени выполнения, * а проблемы реализации, конфигурации или неверного использования API. @@ -38,10 +32,5 @@ * throw new \Rudra\Exceptions\RouterException("503"); * } * ``` - * - * @package Rudra\Exceptions */ - -namespace Rudra\Exceptions; - class LogicException extends RudraException implements ExceptionInterface {} diff --git a/src/MiddlewareException.php b/src/MiddlewareException.php index 41ee5c2..12a88dd 100644 --- a/src/MiddlewareException.php +++ b/src/MiddlewareException.php @@ -12,9 +12,6 @@ use Rudra\Exceptions\ExceptionInterface; /** - * MiddlewareException - * =================== - * * An exception that is thrown when a middleware-related error occurs, * such as an invalid format, missing class, or incorrect parameters. * @@ -28,12 +25,7 @@ * and not runtime behavior. * * This exception implements ExceptionInterface for unified filtering and catching across the framework. - * - * @package Rudra\Exceptions - * ---------------------------------------------------------------------------- - * MiddlewareException - * =================== - * + * --------------------- * Исключение, выбрасываемое при возникновении ошибки, связанной с middleware, например: * - Неверный формат middleware * - Отсутствующий или неназванный класс middleware @@ -48,7 +40,5 @@ * а не с состоянием среды выполнения. * * Реализует ExceptionInterface для унифицированной обработки всех исключений в рамках фреймворка. - * - * @package Rudra\Exceptions */ class MiddlewareException extends LogicException implements ExceptionInterface {} diff --git a/src/NotFoundException.php b/src/NotFoundException.php index a934f54..ba14dc3 100644 --- a/src/NotFoundException.php +++ b/src/NotFoundException.php @@ -9,4 +9,11 @@ namespace Rudra\Exceptions; +/** + * Custom exception class for handling "Not Found" errors. + * This exception is typically thrown when a requested resource, service, or data is not found. + * ------------------------- + * Пользовательский класс исключения для обработки ошибок "Не найдено". + * Это исключение обычно выбрасывается, когда запрашиваемый ресурс, сервис или данные не найдены. + */ class NotFoundException extends RudraException {} \ No newline at end of file diff --git a/src/RequestException.php b/src/RequestException.php deleted file mode 100644 index 8359e84..0000000 --- a/src/RequestException.php +++ /dev/null @@ -1,12 +0,0 @@ - - * @license https://mit-license.org/ MIT - */ - -namespace Rudra\Exceptions; - -class RequestException extends RudraException {} diff --git a/src/RouterException.php b/src/RouterException.php index 71bda7d..525d147 100755 --- a/src/RouterException.php +++ b/src/RouterException.php @@ -15,9 +15,6 @@ use Rudra\Redirect\RedirectFacade as Redirect; /** - * RouterException - * =============== - * * Represents an exception that occurs during route registration or dispatching. * This exception is used when a route cannot be matched or dispatched correctly. * @@ -31,12 +28,7 @@ * ``` * * Will redirect to the configured error handler for "404" (if defined). - * - * @package Rudra\Exceptions - * ---------------------------------------------------------------------------- - * RouterException - * =============== - * + * ------------------------- * Представляет исключение, возникающее при регистрации или диспетчеризации маршрутов. * Используется, когда маршрут не может быть найден или выполнен корректно. * @@ -50,8 +42,6 @@ * ``` * * Перенаправит на обработчик ошибок, определённый в конфигурации для кода "404". - * - * @package Rudra\Exceptions */ class RouterException extends RudraException { @@ -60,19 +50,15 @@ class RouterException extends RudraException * * The exception handler will catch all unhandled exceptions of this type * and redirect them using RedirectFacade to the appropriate error page/controller. - * - * @param string $message Optional. Error message (e.g., '404', '503') - * @param int $code Optional. Error code - * @param \Exception|null $previous Previous exception if available - * ---------------------------------------------------------------------------- + * ------------------------- * Конструктор RouterException устанавливает глобальный обработчик исключений. * * Обработчик перехватывает все неперехваченные исключения этого типа * и вызывает RedirectFacade для перехода к странице/контроллеру ошибки. * - * @param string $message Необязательный. Сообщение об ошибке (например: '404', '503') - * @param int $code Необязательный. Код ошибки - * @param \Exception|null $previous Предыдущее исключение, если оно есть + * @param string $message + * @param int $code + * @param \Exception|null $previous */ public function __construct($message = "", $code = 0, ?Exception $previous = null) { @@ -85,29 +71,14 @@ public function __construct($message = "", $code = 0, ?Exception $previous = nul * * Uses RedirectFacade to send an HTTP status code and then calls the error handler, * which is defined in the config under `http.errors`. - * - * Example config: - * 'http' => [ - * 'errors' => [ - * '404' => ['controller' => 'ErrorController', 'action' => 'notFound'] - * ] - * ] - * - * @param \Exception $exception Thrown exception object - * ---------------------------------------------------------------------------- + * ------------------------- * Собственный обработчик исключений, запускаемый этим классом. * * Использует RedirectFacade для отправки HTTP-статуса и вызова обработчика ошибок, * указанного в конфигурации под ключом `http.errors`. - * - * Пример конфигурации: - * 'http' => [ - * 'errors' => [ - * '404' => ['controller' => 'ErrorController', 'action' => 'notFound'] - * ] - * ] - * - * @param \Exception $exception Брошенное исключение + * + * @param \Exception $exception + * @return void */ public function exception_handler(\Exception $exception): void { diff --git a/src/RudraException.php b/src/RudraException.php index 3eb9fcd..50bcf60 100755 --- a/src/RudraException.php +++ b/src/RudraException.php @@ -12,9 +12,6 @@ use RuntimeException; /** - * RudraException - * ============== - * * Base exception class for all exceptions thrown by the Rudra framework. * This class serves as the root of the exception hierarchy and implements ExceptionInterface. * @@ -33,12 +30,7 @@ * // Handle any Rudra-related exception uniformly * } * ``` - * - * @package Rudra\Exceptions - * ---------------------------------------------------------------------------- - * RudraException - * ============== - * + * --------------------- * Базовый класс исключений для всех ошибок, генерируемых фреймворком Rudra. * Этот класс служит корневым элементом иерархии исключений и реализует ExceptionInterface. * @@ -58,8 +50,6 @@ * // Единым образом обрабатываем любые исключения Rudra * } * ``` - * - * @package Rudra\Exceptions */ class RudraException extends RuntimeException implements ExceptionInterface {