/** * Checks the response from the HTTP request for a variety of errors and issues * and raises appropriate exceptions if detected. * * @param HttpfulRequest $response * * @throws MyPlexAuthenticationException * @throws MyPlexDataException */ private function errorCheck($response) { if ($response->hasErrors()) { if ($response->code == 401) { throw new MyPlexAuthenticationException((string) $response->body->error); } $error = 'Error code ' . $response->code . ' recieved from server'; if ($response->hasBody() && isset($response->body->error)) { $error .= ': ' . (string) $response->body->error; } throw new MyPlexDataException($error); } }