yolo/errors

A package for yolo errors

v1.0.3 2024-05-11 03:40 UTC

This package is not auto-updated.

Last update: 2024-05-11 03:42:22 UTC


README

An error handling package for the yolo microservices framework.

Usage

  • Register error module and types.

    $registry = \Yolo\Errors\ExceptionRegistry::inst();
    $registry->createExceptionRegistry(
      'user.service.com',
      [
          'user' => [
              'index' => Number::createIncreaseCodeIndex(1000000)
          ]
      ]
    );
    
  • Register an error

    $registry->register(
      (new \Yolo\Errors\ResponseError('user', 'user_not_found', 'User not found.'))->setHttpStatus(404)
    );
    
  • Throw a new error

    throw \Yolo\Service\ApiGateway::responseError('user_not_found', [
      'userId' => 123,
    ]);
    

It will throw a YoloException, which will be caught and handled by the framework and returned.