ExampleException.php 350 B

12345678910111213141516171819
  1. <?php
  2. namespace App\Exceptions;
  3. use Exception;
  4. class ExampleException extends Exception
  5. {
  6. /**
  7. * 转换异常为 HTTP 响应
  8. *
  9. * @param \Illuminate\Http\Request
  10. * @return \Illuminate\Http\Response
  11. */
  12. public function render($request)
  13. {
  14. return response($this->getMessage() ?: '发生异常啦');
  15. }
  16. }