# Yolo错误包 **Repository Path**: lushaoming/yolo-errors ## Basic Information - **Project Name**: Yolo错误包 - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-05-08 - **Last Updated**: 2024-05-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Yolo Errors An error handling package for the yolo microservices framework. ## Usage - Register error module and types. ```php $registry = \Yolo\Errors\ExceptionRegistry::inst(); $registry->createExceptionRegistry( 'user.service.com', [ 'user' => [ 'index' => Number::createIncreaseCodeIndex(1000000) ] ] ); ``` - Register an error ```php $registry->register( (new \Yolo\Errors\ResponseError('user', 'user_not_found', 'User not found.'))->setHttpStatus(404) ); ``` - Throw a new error ```php 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.