added exception for invalid/no api key

This commit is contained in:
danijoo
2014-01-01 22:41:49 +01:00
parent 80aba28864
commit 2b77b1443f
3 changed files with 7 additions and 2 deletions

View File

@@ -42,6 +42,9 @@ end
# Base class for exceptions raised by the gem
class SightstoneApiException < Exception; end
# Raised if no or an invalid api key was passed to the api
class InvalidApiKeyException < SightstoneApiException; end
# Raised if the given developer cannot be found (api returns http error code 404)
class SummonerNotFoundException < SightstoneApiException; end

View File

@@ -28,9 +28,11 @@ class SightstoneBaseModule
raise Sightstone::SightstoneConnectionException
elsif response_code == 429
raise Sightstone::RateLimitExceededException
elsif response_code == 401
raise Sightstone::InvalidApiKeyException
else
raise Sightstone::SightstoneApiException 'Unknown error occured'
end
end
end
end