<?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()
        ]);
    }
}
