1
0
mirror of https://github.com/flarum/core.git synced 2025-10-12 07:24:27 +02:00

Use exception handlers instead of JsonApiSerializableInterface

This commit is contained in:
Toby Zerner
2015-10-26 11:12:10 +10:30
parent f3612261ec
commit 68498cedae
14 changed files with 326 additions and 141 deletions

View File

@@ -25,11 +25,18 @@ class Client
protected $container;
/**
* @param Container $container
* @var ErrorHandler
*/
public function __construct(Container $container)
protected $errorHandler;
/**
* @param Container $container
* @param ErrorHandler $errorHandler
*/
public function __construct(Container $container, ErrorHandler $errorHandler)
{
$this->container = $container;
$this->errorHandler = $errorHandler;
}
/**
@@ -55,11 +62,9 @@ class Client
}
try {
$response = $controller->handle($request);
return $controller->handle($request);
} catch (Exception $e) {
$response = $this->container->make('Flarum\Api\Middleware\HandleErrors')->handle($e);
return $this->errorHandler->handle($e);
}
return $response;
}
}