fivelab/error 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fivelab/error

最新稳定版本:v1.0

Composer 安装命令:

composer require fivelab/error

包简介

Control error codes with many systems

README 文档

README

With this package, you can control error codes and exceptions in system with many sub systems.

Installation

Add FiveLab/Error in your composer.json:

{
    "require": {
        "fivelab/error": "~1.0"
    }
}

Now tell composer to download the library by running the command:

$ php composer.phar update fivelab/error

Basic usage

For collect all error codes, you must create a error factory in you sub system:

use FiveLab\Component\Error\ErrorFactoryInterface;

final class MySystemError implements ErrorFactoryInterface
{
    const ERROR_1 = 1;
    const ERROR_2 = 2;

    public function getErrors()
    {
        return [
            self::ERROR_1 => 'Error #1',
            self::ERROR_2 => 'Error #2'
        ];
    }

    public function getExceptions()
    {
        return [];
    }

    public function getReservedDiapason()
    {
        return [1, 5];
    }
}

And create error system (Storage), and add this factory to storage:

use FiveLab\Component\Error\Errors;

$errors = new Errors();
$errors->addFactory(new MySystemError());

After, you can:

  1. Get reserved diapasons for each system
    $errors->getReservedCodes();
  2. Get all errors for system
    $errors->getErrors();
  3. Get all exceptions
    $exceptions = $errors->getExceptions();
  4. Check, if has exception in errors storage
    $exception = new \Exception();
    $errors->hasException($exception);
  5. Get error code for exception
    $exception = new \Exception();
    $code = $errors->getExceptionCode($exception);
  6. Check reserved codes
    $errors->checkReservedCodes();

统计信息

  • 总下载量: 1.12k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-15