Skip to content

slash-dw/error-kit

Repository files navigation

slash-dw/error-kit

A Laravel package for structured domain errors.

Requirements

  • PHP ^8.5
  • Laravel ^13.0

Exact Laravel component constraints are defined in composer.json.

What This Package Provides

  • Structured domain exception contract and base class
  • Report behavior enum
  • Code composer (segment pack/unpack)
  • In-memory error code registry
  • Exception reporting policy contract and default implementation

Quick Usage

use SlashDw\ErrorKit\Domain\AbstractStructuredDomainException;
use SlashDw\ErrorKit\Enums\ReportBehavior;

final class OrderCannotBeCancelled extends AbstractStructuredDomainException
{
    public function errorCode(): int { return 1001001; }
    public function errorSlug(): string { return 'order.cannot_cancel'; }
    public function developerMessage(): string { return 'Order already shipped.'; }
    public function userMessageKey(): string { return 'orders.cannot_cancel'; }
    public function reportBehavior(): ReportBehavior { return ReportBehavior::Warning; }
}

Test Status

  • PHPUnit: 24 tests / 40 assertions
  • PHPStan: clean
  • Pint: passed

Dev Commands

composer install
./vendor/bin/phpunit -c phpunit.xml.dist
./vendor/bin/phpstan analyse -c phpstan.neon.dist --memory-limit=1G
./vendor/bin/pint --format agent

About

Shared Laravel error handling primitives: structured domain exceptions, error code composition, registry, and reporting policy contracts.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages