mirror of
https://github.com/flarum/core.git
synced 2025-10-12 07:24:27 +02:00
Improve API error handling
- Change 'path' key to 'source.pointer', as per spec - Add 500 error detail if debug mode is on
This commit is contained in:
@@ -12,6 +12,8 @@ namespace Flarum\Api;
|
||||
|
||||
use Flarum\Core\Users\User;
|
||||
use Illuminate\Contracts\Container\Container;
|
||||
use Exception;
|
||||
use Flarum\Api\Middleware\JsonApiErrors;
|
||||
|
||||
class Client
|
||||
{
|
||||
@@ -41,7 +43,13 @@ class Client
|
||||
/** @var \Flarum\Api\Actions\Action $action */
|
||||
$action = $this->container->make($actionClass);
|
||||
|
||||
$response = $action->handle(new Request($input, $actor));
|
||||
try {
|
||||
$response = $action->handle(new Request($input, $actor));
|
||||
} catch (Exception $e) {
|
||||
$middleware = new JsonApiErrors();
|
||||
|
||||
$response = $middleware->handle($e);
|
||||
}
|
||||
|
||||
return new Response($response);
|
||||
}
|
||||
|
Reference in New Issue
Block a user