QQException.php 709 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\Services\QQMiniApp;
  3. use Exception;
  4. use Illuminate\Http\Response;
  5. use Throwable;
  6. class QQException extends Exception
  7. {
  8. public function __construct(string $message = "QQ请求失败", int $code = 500, Throwable $previous = null)
  9. {
  10. parent::__construct($message, $code, $previous);
  11. }
  12. /**
  13. * 将异常渲染到 HTTP 响应中。
  14. *
  15. * @param \Illuminate\Http\Request $request
  16. * @return Response
  17. */
  18. public function render($request)
  19. {
  20. return response([
  21. 'code' => 500,
  22. 'status_code' => 500,
  23. 'error_code' => $this->getCode(),
  24. 'message' => $this->getMessage(),
  25. ]);
  26. }
  27. }