Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 46 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,52 @@
-----

# Rudra-Exception | [API](https://github.com/Jagepard/Rudra-Exception/blob/master/docs.md "Documentation API")
#### Установка / Install
```composer require rudra/exception```
#### Install
```bash
composer require rudra/exception
```
#### Usage
##### Throwing HTTP Errors
```php
// Using abort() helper
abort(404);
abort(500, "Internal Server Error");

// Or directly
throw new RouterException("Not Found", 404);
throw new NotFoundException("Resource not found");
throw new LogicException("Invalid configuration");
```
#### Exception Hierarchy
```text
Throwable
└── RuntimeException
└── RudraException
├── RouterException
├── LogicException
│ └── MiddlewareException
├── NotFoundException
└── RuntimeException
```
#### Configuration
##### Error Pages
Configure error handlers in your ```setting.{$env}.yml```:
```yml
http.errors:
404:
controller: App\Ship\Errors\Controller\HttpErrorsController
action: error404
503:
controller: App\Ship\Errors\Controller\HttpErrorsController
action: error503
```
#### DebugBar Integration
In development mode, exceptions are automatically logged to DebugBar:
```php
if (Rudra::config()->get("environment") === "development") {
$debugbar->addCollector(new DebugBar\DataCollector\ExceptionsCollector());
}
```
## License

This project is licensed under the **Mozilla Public License 2.0 (MPL-2.0)** — a free, open-source license that:
Expand All @@ -18,14 +61,4 @@ This project is licensed under the **Mozilla Public License 2.0 (MPL-2.0)** —
- Permits combining with proprietary code in larger works.

📄 Full license text: [LICENSE](./LICENSE)
🌐 Official MPL-2.0 page: https://mozilla.org/MPL/2.0/

--------------------------
Проект распространяется под лицензией **Mozilla Public License 2.0 (MPL-2.0)**. Это означает:
- Вы можете свободно использовать, изменять и распространять код.
- При изменении файлов, содержащих исходный код из этого репозитория, вы обязаны оставить их открытыми под той же лицензией.
- Вы **обязаны сохранять уведомления об авторстве** и ссылку на оригинал.
- Вы можете встраивать код в проприетарные проекты, если исходные файлы остаются под MPL.

📄 Полный текст лицензии (на английском): [LICENSE](./LICENSE)
🌐 Официальная страница: https://mozilla.org/MPL/2.0/
🌐 Official MPL-2.0 page: https://mozilla.org/MPL/2.0/
19 changes: 8 additions & 11 deletions tests/ExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@
* @author Korotkov Danila (Jagepard) <jagepard@yandex.ru>
* @license https://mozilla.org/MPL/2.0/ MPL-2.0
*
* phpunit src/tests/ContainerTest --coverage-html src/tests/coverage-html
* phpunit src/tests/ExceptionTest --coverage-html src/tests/coverage-html
*/

use Rudra\Exceptions\{
LogicException,
RudraException,
RouterException,
RuntimeException,
NotFoundException,
MiddlewareException,
};
use PHPUnit\Framework\TestCase;
use Rudra\Exceptions\LogicException;
use Rudra\Exceptions\RudraException;
use Rudra\Exceptions\RouterException;
use Rudra\Exceptions\RuntimeException;
use Rudra\Exceptions\NotFoundException;
use Rudra\Exceptions\MiddlewareException;

class ExceptionTest extends TestCase
class ExceptionTest extends \PHPUnit\Framework\TestCase
{
protected function tearDown(): void
{
Expand Down
Loading