NoticeException.php 722 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Exceptions;
  3. use Exception;
  4. use Throwable;
  5. /**
  6. * 通知发送异常
  7. * Class NoticeException
  8. * @package App\Exceptions
  9. */
  10. class NoticeException extends Exception
  11. {
  12. //
  13. public function __construct(string $message = "", int $code = 200, Throwable $previous = null)
  14. {
  15. parent::__construct($message, $code, $previous);
  16. }
  17. /**
  18. * 将异常渲染到 HTTP 响应中。
  19. *
  20. * @param \Illuminate\Http\Request
  21. * @return void
  22. */
  23. public function render($request)
  24. {
  25. return response([
  26. 'code' => $this->getCode(),
  27. 'error' => $this->getMessage(),
  28. 'message' => '请求成功,通知失败'
  29. ]);
  30. }
  31. }