阶段性提交代码
This commit is contained in:
45
app/Exceptions/ApiUnionpayException.php
Normal file
45
app/Exceptions/ApiUnionpayException.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: sai
|
||||
* Date: 2020/1/15
|
||||
* Time: 14:31
|
||||
*/
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
class ApiUnionpayException extends \Exception
|
||||
{
|
||||
|
||||
const ERROR_CODE = 1001;
|
||||
const ERROR_MSG = 'ApiUnionpayException';
|
||||
|
||||
private $data = [];
|
||||
|
||||
/**
|
||||
* BusinessException constructor.
|
||||
* @param string $message
|
||||
* @param string $code
|
||||
* @param array $data
|
||||
*/
|
||||
public function __construct($data = [])
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 异常输出
|
||||
*/
|
||||
public function render($request)
|
||||
{
|
||||
return response()->json($this->getData(), 200);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,18 +7,17 @@ use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
|
||||
/**
|
||||
* A list of the exception types that are not reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
//
|
||||
ApiException::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* A list of the inputs that are never flashed for validation exceptions.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontFlash = [
|
||||
@@ -28,24 +27,24 @@ class Handler extends ExceptionHandler
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* @param \Exception $exception
|
||||
* @param \Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $exception)
|
||||
{
|
||||
info($exception->getMessage());
|
||||
parent::report($exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $exception
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $exception)
|
||||
{
|
||||
return parent::render($request, $exception);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user