Browse Source

增加TypeError && ParseError && Error错误输出

dev
李可松 4 years ago
parent
commit
26fc66f10d
  1. 22
      app/Exceptions/Handler.php

22
app/Exceptions/Handler.php

@ -75,6 +75,17 @@ class Handler extends ExceptionHandler
'status' => 500, 'status' => 500,
]); ]);
} }
//TypeError && ParseError
if ($e instanceof \TypeError || $e instanceof \ParseError) {
return response()->json([
'code' => -1,
'msg' => $e->getMessage(),
'data' => [],
'status' => 500,
'file' => $e->getFile(),
'line' => $e->getLine(),
]);
}
//Exception //Exception
if ($e instanceof \Exception) { if ($e instanceof \Exception) {
return response()->json([ return response()->json([
@ -84,6 +95,17 @@ class Handler extends ExceptionHandler
'status' => 500, 'status' => 500,
]); ]);
} }
//Exception
if ($e instanceof \Error) {
return response()->json([
'code' => -1,
'msg' => $e->getMessage(),
'data' => [],
'status' => 500,
'file' => $e->getFile(),
'line' => $e->getLine(),
]);
}
return parent::render($request, $e); return parent::render($request, $e);
} }
} }
Loading…
Cancel
Save