12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- namespace App\Exceptions;
- use Exception;
- use Throwable;
- /**
- * 非200正常返回的情况前端弹
- * Class AlertException
- * @package App\Exceptions
- */
- class AlertException extends Exception
- {
- public function __construct(string $message = "", int $code = 400, Throwable $previous = null)
- {
- parent::__construct($message, $code, $previous);
- }
- /**
- * 将异常渲染到 HTTP 响应中。
- *
- * @param \Illuminate\Http\Request
- * @return void
- */
- public function render($request)
- {
- return response([
- 'code' => $this->getCode(),
- 'status_code' => 400,
- 'message' => $this->getMessage()
- ]);
- }
- }
|