Expanded API code, wrote a bunch new transformers as well.

This commit is contained in:
James Cole
2018-02-11 20:45:33 +01:00
parent 94f6bd34c7
commit c2da5931ec
16 changed files with 891 additions and 97 deletions

View File

@@ -64,7 +64,23 @@ class Handler extends ExceptionHandler
public function render($request, Exception $exception)
{
if ($exception instanceof NotFoundHttpException && $request->expectsJson()) {
return response()->json(['message' => 'Not found'], 404);
return response()->json(['message' => 'Resource not found', 'exception' => 'NotFoundHttpException'], 404);
}
if ($request->expectsJson()) {
$isDebug = env('APP_DEBUG', false);
if ($isDebug) {
return response()->json(
[
'message' => $exception->getMessage(),
'exception' => get_class($exception),
'line' => $exception->getLine(),
'file' => $exception->getFile(),
'trace' => $exception->getTrace(),
], 500
);
}
return response()->json(['message' => 'Internal Firefly III Exception. See log files.', 'exception' => get_class($exception)], 500);
}
if ($exception instanceof FireflyException || $exception instanceof ErrorException) {