1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace App\Exceptions;
- use Exception;
- use Throwable;
- /**
- * 数据库DB的异常
- * Class DBException
- * @package App\Exceptions
- */
- class DBException extends Exception
- {
- public function __construct(string $message = "", int $code = 501, 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' => 500,
- 'error' => $this->getMessage(),
- 'message' => '网络异常,请稍后重试![DB]'
- ]);
- }
- }
|