protected function resolveExceptionClass(ClientException $exception) { $response = $exception->getResponse()->getBody(); $response = json_decode($response->getContents()); if ($response === null) { return new Exception($exception->getMessage()); } $meta = isset($response->meta) ? $response->meta : $response; $class = '\\Larabros\\Elogram\\Exceptions\\' . $meta->error_type; return new $class($meta->error_message); }