public static function convertError($response) { if (property_exists($response->body, 'errors')) { $error = Error::createFromResponse($response); } else { $error = new HTTPError($response); } return $error; }