1
0
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:
Toby Zerner
2015-09-14 15:40:07 +09:30
parent b7d8afe6a4
commit 8cccaaaf6b
5 changed files with 54 additions and 27 deletions

View File

@@ -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);
}