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")
pull/2732/head
Wv5twkFEKh54vo4tta9yu7dHa3 2021-04-20 18:18:42 +02:00 zatwierdzone przez GitHub
rodzic 6a570d07ec
commit a19d4d5418
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 5 dodań i 0 usunięć

Wyświetl plik

@ -48,6 +48,11 @@ class Handler extends ExceptionHandler
*/
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);
}
}