Version 5.1 - All the GraphQL #32
@ -18,6 +18,7 @@ namespace Aviat\AnimeClient;
|
|||||||
|
|
||||||
use Aviat\Ion\Di\ContainerInterface;
|
use Aviat\Ion\Di\ContainerInterface;
|
||||||
use Aviat\Ion\Friend;
|
use Aviat\Ion\Friend;
|
||||||
|
use GuzzleHttp\Exception\ServerException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic routing/ dispatch
|
* Basic routing/ dispatch
|
||||||
@ -129,8 +130,22 @@ class Dispatcher extends RoutingBase {
|
|||||||
$params = $error_route['params'];
|
$params = $error_route['params'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actually instantiate the controller
|
// Try to catch API errors in a presentable fashion
|
||||||
$this->call($controllerName, $actionMethod, $params);
|
try
|
||||||
|
{
|
||||||
|
// Actually instantiate the controller
|
||||||
|
$this->call($controllerName, $actionMethod, $params);
|
||||||
|
}
|
||||||
|
catch (ServerException $e)
|
||||||
|
{
|
||||||
|
$response = $e->getResponse();
|
||||||
|
$this->call(AnimeClient::DEFAULT_CONTROLLER, AnimeClient::ERROR_MESSAGE_METHOD, [
|
||||||
|
$response->getStatusCode(),
|
||||||
|
'API Error',
|
||||||
|
'There was a problem getting data from an external source.',
|
||||||
|
(string) $response->getBody()
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user