Notification.php 828 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace rest\common\exception;
  3. use Exception;
  4. use think\exception\Handle;
  5. use think\exception\HttpException;
  6. class Notification extends Handle
  7. {
  8. public function render(Exception $e)
  9. {
  10. /* // 参数验证错误
  11. if ($e instanceof ValidateException) {
  12. return json($e->getError(), 422);
  13. }
  14. // 请求异常
  15. if ($e instanceof HttpException && request()->isAjax()) {
  16. return response($e->getMessage(), $e->getStatusCode());
  17. }*/
  18. //TODO::开发者对异常的操作
  19. $errorContent = $e->getMessage().' '.$e->getFile().' '.$e->getLine().'行';
  20. //echo $errorContent;
  21. if(function_exists('error_notify')) error_notify($errorContent);
  22. //可以在此交由系统处理
  23. return parent::render($e);
  24. }
  25. }