123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php namespace App\Exceptions\Admin;
- use Exception;
- use Throwable;
- /**
- * 接口异常
- */
- class AuthException extends Exception
- {
- public $msg = '';
- public $url = '';
- public $wait = 3;
- /**
- * 抛出错误信息
- *
- * @param String $msg 错误提示
- * @param Mixed $url 跳转地址
- * @param Array $wait 等待时间
- *
- */
- public function __construct($msg='',$url='',$wait=3)
- {
- $this->msg = $msg;
- $this->url = $url;
- $this->wait = $wait;
- }
- /**
- * 错误提示
- *
- */
- public function jumpPage(){
- $url = $this->url;
- $msg = $this->msg;
- $wait = $this->wait;
- // 处理路径
- if ( is_null($url) ) {
- $url = request()->ajax() ? '' : 'javascript:history.back(-1);';
- } elseif ('' !== $url) {
- $url = (strpos($url, '://') || 0 === strpos($url, '/')) ? $url : url($url);
- }
- // 返回结果
- return $wait ? response(view('error',['msg'=>$msg,'url'=>$url,'wait'=>$wait])) : redirect($url,302);
- }
- }
|