mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-26 08:13:16 +00:00
Use same json error format as Mastodon
As documented in the Mastodon API ( https://docs.joinmastodon.org/entities/error/ ), error responses use "error" as the key for the value, instead of Laravel's default (which is "message")
This commit is contained in:
parent
6a570d07ec
commit
a19d4d5418
1 changed files with 5 additions and 0 deletions
|
@ -48,6 +48,11 @@ class Handler extends ExceptionHandler
|
||||||
*/
|
*/
|
||||||
public function render($request, Throwable $exception)
|
public function render($request, Throwable $exception)
|
||||||
{
|
{
|
||||||
|
if ($request->wantsJson())
|
||||||
|
return response()->json(
|
||||||
|
['error' => $exception->getMessage()],
|
||||||
|
method_exists($exception, 'getStatusCode') ? $exception->getStatusCode() : 500
|
||||||
|
);
|
||||||
return parent::render($request, $exception);
|
return parent::render($request, $exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue