*
Showing
2 changed files
with
28 additions
and
2 deletions
| ... | @@ -5,6 +5,7 @@ namespace App\Exceptions; | ... | @@ -5,6 +5,7 @@ namespace App\Exceptions; |
| 5 | use App\Helper\ErrorCode; | 5 | use App\Helper\ErrorCode; |
| 6 | use App\Helper\Response; | 6 | use App\Helper\Response; |
| 7 | use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; | 7 | use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; |
| 8 | use Illuminate\Support\Facades\Log; | ||
| 8 | use Illuminate\Validation\ValidationException; | 9 | use Illuminate\Validation\ValidationException; |
| 9 | use Throwable; | 10 | use Throwable; |
| 10 | 11 | ||
| ... | @@ -16,7 +17,7 @@ class Handler extends ExceptionHandler | ... | @@ -16,7 +17,7 @@ class Handler extends ExceptionHandler |
| 16 | * @var array | 17 | * @var array |
| 17 | */ | 18 | */ |
| 18 | protected $dontReport = [ | 19 | protected $dontReport = [ |
| 19 | // | 20 | ValidationException::class |
| 20 | ]; | 21 | ]; |
| 21 | 22 | ||
| 22 | /** | 23 | /** |
| ... | @@ -42,5 +43,30 @@ class Handler extends ExceptionHandler | ... | @@ -42,5 +43,30 @@ class Handler extends ExceptionHandler |
| 42 | }); | 43 | }); |
| 43 | } | 44 | } |
| 44 | 45 | ||
| 46 | /** | ||
| 47 | * @param Throwable $e | ||
| 48 | * @throws Throwable | ||
| 49 | */ | ||
| 50 | public function report(Throwable $e) | ||
| 51 | { | ||
| 52 | parent::report($e); | ||
| 53 | } | ||
| 54 | |||
| 55 | /** | ||
| 56 | * @param \Illuminate\Http\Request $request | ||
| 57 | * @param Throwable $e | ||
| 58 | * @return \Illuminate\Http\JsonResponse|\Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response | ||
| 59 | * @throws Throwable | ||
| 60 | */ | ||
| 61 | public function render($request, Throwable $e) | ||
| 62 | { | ||
| 63 | if ($e instanceof ValidationException) { | ||
| 64 | Log::error(__METHOD__, ['uri'=>$request->getUri(), 'params'=> $request->all(), 'err'=>$e->errors()]); | ||
| 65 | return Response::error(ErrorCode::ILLEGAL_PARAMS, $e->validator->errors()->first()); | ||
| 66 | } else { | ||
| 67 | return parent::render($request, $e); // TODO: Change the autogenerated stub | ||
| 68 | } | ||
| 69 | } | ||
| 70 | |||
| 45 | 71 | ||
| 46 | } | 72 | } | ... | ... |
| ... | @@ -14,5 +14,5 @@ use Illuminate\Support\Facades\Route; | ... | @@ -14,5 +14,5 @@ use Illuminate\Support\Facades\Route; |
| 14 | */ | 14 | */ |
| 15 | Route::group([], function (){ | 15 | Route::group([], function (){ |
| 16 | //提现审核通过 | 16 | //提现审核通过 |
| 17 | Route::post('musician/withdraw', 'MusicianWithdrawController@withdraw'); | 17 | Route::get('musician/withdraw', 'MusicianWithdrawController@withdraw'); |
| 18 | }); | 18 | }); | ... | ... |
-
Please register or sign in to post a comment