undercloud/exceptor

异常处理流程

dev-master 2021-10-16 19:10 UTC

This package is auto-updated.

Last update: 2024-09-17 02:10:37 UTC


README

Build Status

异常处理流程

安装

composer require undercloud/exceptor

需求

PHP 5.4+

描述

在应用程序流程中提供捕获错误和异常的机制。所有内置的错误类型都被转换为异常,这极大地简化了调试过程。它还拦截由于内存不足和执行超时导致的错误。

用法

// catch all
error_reporting(E_ALL);

use Undercloud\Exception\FlowHandler;

(new FlowHandler(function(){
    try {
        // your code
    // PHP 5.x 
    } catch (Exception $e) {
        return $e;
    // PHP 7.x
    } catch (Throwable $e) {
        return $e;
    }
}))->flow(function($e){
    // handle exception
})

异常类型

  • 所有标准的PHP异常
  • CompileErrorException
  • CompileWarningException
  • CoreErrorException
  • CoreWarningException
  • DeprecatedException
  • NoticeException
  • ParseException
  • RecoverableErrorException
  • StrictException
  • UserDeprecatedException
  • UserErrorException
  • UserNoticeException
  • UserWarningException
  • WarningException
  • ExecutionTimeoutException
  • OutOfMemoryException

许可

MIT