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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user