mggflow/exception-manager

v3.3.0 2023-03-11 14:28 UTC

This package is auto-updated.

Last update: 2024-09-11 17:52:12 UTC


README

关于

此包用于创建基于异常意义的通用异常代码。

用法

安装方法

composer require mggflow/exception-manager

示例

try {
    throw ManageException::build()
        ->log()->warning()->b()
        ->desc()->internal()->tooMany(null, 'Requests')
        ->context(uniqid(), 'importantID')->b()
        ->fill();
} catch (UniException $uniException) {
    echo '<pre>';
    var_dump($uniException->getCode());
    var_dump($uniException->getMessage());
    var_dump($uniException->getInternalMessage());
    var_dump($uniException->getLogLvl());
    var_dump($uniException->getContext());
    var_dump($uniException->getMessageParts());
    echo '</pre>';
}

预期输出

int(13)
string(14) "Internal Error"
string(17) "Too many Requests"
int(32)
array(1) {
  ["importantID"]=>
  string(13) "64050ff0be4fa"
}
array(1) {
  [0]=>
  array(2) {
    [0]=>
    int(13)
    [1]=>
    array(2) {
      [0]=>
      string(8) "too many"
      [1]=>
      string(8) "Requests"
    }
  }
}