b2r/exception

b2r 异常组件

v0.3.0 2017-03-09 04:41 UTC

This package is not auto-updated.

Last update: 2024-09-28 20:20:07 UTC


README

我库中常见的异常

Build Status

  • 所有异常实现 ExceptionInterface
  • 所有异常使用 ExceptionTrait
  • CHANGELOG
  • Packagist

异常类

  • 异常
    • InvalidClassMemberException
      • InvalidMethodException
      • InvalidPropertyException
    • InvalidIndexException
    • InvalidKeyException
    • InvalidTypeException
      • InvalidParameterTypeException
    • IOException
      • FileNotFoundException
      • DirectoryNotFoundException
    • NameException
  • InvalidArgumentException
  • LogicException
  • RuntimeException
  • ValidationException

实用/辅助类

  • Utils: 实用函数
  • Finder: 查找/解析类名

InvalidTypeException 示例

use b2r\Component\Exception\InvalidTypeException;

$e = new InvalidTypeException('$key', 'string|int', []); // Variable name, Valid type, Invalid type value
echo $e->message; #=>"$key must be of the type `string|int`, but `array` given"

Finder 示例

使用Finder轻松查找/解析类名。

use b2r\Component\Exception\Finder as E;

$e = E::Type(); #=>'b2r\Component\Exception\InvalidTypeException'
throw new $e('name', 'string|int', null);