lib/travis/client/session.rb in travis-1.8.10.travis.994.9 vs lib/travis/client/session.rb in travis-1.8.10.travis.997.9

- old
+ new

@@ -216,10 +216,16 @@ when 0 then raise Travis::Client::SSLError, 'SSL error: could not verify peer' when 200..299 then JSON.parse(result.body) rescue result.body when 301, 303 then raw(:get, result.headers['Location']) when 302, 307, 308 then raw(verb, result.headers['Location']) when 401 then raise Travis::Client::NotLoggedIn, 'not logged in' - when 403 then raise Travis::Client::NotLoggedIn, 'invalid access token' + when 403 then + body = JSON.parse(result.body) rescue {} + if body["error_type"] == "migrated_repository" + raise Travis::Client::RepositoryMigrated, body["error_message"] + else + raise Travis::Client::NotLoggedIn, 'invalid access token' + end when 404 then raise Travis::Client::NotFound, result.body when 422 then raise Travis::Client::ValidationFailed, result.body when 400..499 then raise Travis::Client::Error, "%s: %p" % [result.status, result.body] when 500..599 then raise Travis::Client::Error, "server error (%s: %p)" % [result.status, result.body] else raise Travis::Client::Error, "unhandled status code #{result.status}"