Skip to content

Commit

Permalink
Add BadRPCException for code 3
Browse files Browse the repository at this point in the history
Subclass InvalidRPCException with a new one for code 3s only, rename
PgoapiError to AiopogoError.
  • Loading branch information
Noctem committed Mar 3, 2017
1 parent 4e4bbdb commit 06ec484
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 30 deletions.
9 changes: 0 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,3 @@ install:
- python setup.py install
script:
- python -c 'import aiopogo'
deploy:
provider: pypi
user: Noctem
password:
secure: WHnVJnKCR7qzrW2vufYu6X+VFj2E5dRfBuSBeckoddP7J4ggE2XSORz8aqVyDNVzLD/+F/SKlFyqrYCvtooJwMtSRFVLdhmHgF+yfI+c42nWyUMPjZHlEZ7DorDykh/iwqX6cmIzxnSUdyZQthtPezQNFPP54tahUFHSbw6v+n48qPVHX60U6p97vZN995hMcskRNAdTXfoAzE/nXdjEqnG5JfrAjPdIMX0+8bab4qI6NiBdPrC4iNfe7zXJjvdh1IlkWbaIEp53/PTWjmE04IrEO44gWklJZVvzlAz2GWyK40mj45E+E4dIdLdrkUAJvzlXREYhAv1ImgGxND2y+BP9sFVBMlUxZsCLF8uh0kcdzE013Z0lwtzUQBhS/ukPEefzq4cGAhYDZtL4lW6NvGGDugq7gXzSbTtpxm3w/kMt4fDduJa7lz58S7fq6tHeml7DB8vLNWlQBv5ezcClPo7i4mNo7tEE8+2IStuCOTPgqGm8Hfi+3nqsBnYJCiHL9GAe2V6eP2eaNsb/HpDa20MI9pNz4iFXfNUYrzd3Xs2hS2ELkmg708487KytTdhroZOmgsiz99JCBJIWYT5GVtQYaP7LDUoF75TJo1hqMFpADOSwgCcZDjoup4tkBV3VhyQ2owvcHqvfN9K8NQJlmTazpFPhfe6qfsWW4KAcZTY=
on:
tags: true
distributions: sdist bdist_wheel
repo: Noctem/aiopogo
40 changes: 20 additions & 20 deletions aiopogo/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
class SocksError(Exception): pass


class PgoapiError(Exception):
class AiopogoError(Exception):
"""Any custom exception in this module"""

class HashServerException(PgoapiError):
class HashServerException(AiopogoError):
"""Parent class of all hashing server errors"""

class ProxyException(ProxyConnectionError, SocksError):
"""Raised when there is an error connecting to a proxy server."""

class TimeoutException(PgoapiError, TimeoutError):
class TimeoutException(AiopogoError, TimeoutError):
"""Raised when a request times out."""


class AuthException(PgoapiError):
class AuthException(AiopogoError):
"""Raised when logging in fails"""

class ActivationRequiredException(AuthException):
Expand All @@ -32,11 +32,11 @@ class InvalidCredentialsException(AuthException, ValueError):
"""Raised when the username, password, or provider are empty/invalid"""


class AuthTokenExpiredException(PgoapiError):
class AuthTokenExpiredException(AiopogoError):
"""Raised when your auth token has expired (code 102)"""


class BadRequestException(PgoapiError):
class BadRequestException(AiopogoError):
"""Raised when HTTP code 400 is returned"""

class BadHashRequestException(BadRequestException, HashServerException):
Expand All @@ -45,34 +45,37 @@ class BadHashRequestException(BadRequestException, HashServerException):
class InvalidRPCException(BadRequestException):
"""Raised when an invalid RPC is made."""

class BadRPCException(InvalidRPCException):
"""Raised when an invalid RPC is made."""


class BannedAccountException(PgoapiError):
class BannedAccountException(AiopogoError):
"""Raised when an account is banned"""


class ExpiredHashKeyException(HashServerException):
"""Raised when a hash key has expired."""


class MalformedResponseException(PgoapiError):
class MalformedResponseException(AiopogoError):
"""Raised when the response is empty or not in an expected format"""

class MalformedNianticResponseException(PgoapiError):
class MalformedNianticResponseException(AiopogoError):
"""Raised when a Niantic response is empty or not in an expected format"""

class MalformedHashResponseException(MalformedResponseException, HashServerException):
"""Raised when the response from the hash server cannot be parsed."""


class NoPlayerPositionSetException(PgoapiError, ValueError):
class NoPlayerPositionSetException(AiopogoError, ValueError):
"""Raised when either lat or lng is None"""


class NotLoggedInException(PgoapiError):
class NotLoggedInException(AiopogoError):
"""Raised when attempting to make a request while not authenticated"""


class ServerBusyOrOfflineException(PgoapiError):
class ServerBusyOrOfflineException(AiopogoError):
"""Raised when unable to establish a connection with a server"""

class AuthConnectionException(AuthException, ServerBusyOrOfflineException):
Expand All @@ -91,11 +94,11 @@ class HashingTimeoutException(HashingOfflineException, TimeoutException):
"""Raised when a request to the hashing server times out."""


class PleaseInstallProtobufVersion3(PgoapiError):
class PleaseInstallProtobufVersion3(AiopogoError):
"""Raised when Protobuf is unavailable or too old"""


class ServerSideAccessForbiddenException(PgoapiError):
class ServerSideAccessForbiddenException(AiopogoError):
"""Raised when access to a server is forbidden"""

class NianticIPBannedException(ServerSideAccessForbiddenException):
Expand All @@ -108,24 +111,21 @@ class TempHashingBanException(HashingForbiddenException):
"""Raised when your IP is temporarily banned for sending too many requests with invalid keys."""


class ServerSideRequestThrottlingException(PgoapiError):
class ServerSideRequestThrottlingException(AiopogoError):
"""Raised when too many requests were made in a short period"""

class NianticThrottlingException(ServerSideRequestThrottlingException):
"""Raised when too many requests to Niantic were made in a short period"""

class HashingQuotaExceededException(ServerSideRequestThrottlingException, HashServerException):
"""Raised when you exceed your hashing server quota"""


class UnexpectedResponseException(PgoapiError):
class UnexpectedResponseException(AiopogoError):
"""Raised when an unhandled HTTP status code is received"""

class UnexpectedHashResponseException(UnexpectedResponseException, HashServerException):
"""Raised when an unhandled HTTP code is received from the hash server"""


class ServerApiEndpointRedirectException(PgoapiError):
class ServerApiEndpointRedirectException(AiopogoError):
"""Raised when the API redirects you to another endpoint"""
def __init__(self):
self._api_endpoint = None
Expand Down
3 changes: 3 additions & 0 deletions aiopogo/rpc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ async def request(self, endpoint, subrequests, player_position):
exception = ServerApiEndpointRedirectException()
exception.set_redirected_endpoint(api_url)
raise exception
elif status_code == 3:
req_type = self.get_request_name(subrequests)
raise BadRPCException("Bad Request on {}".format(req_type))
else:
err = StatusCode(status_code).name
req_type = self.get_request_name(subrequests)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
author = 'David Christenson',
author_email='mail@noctem.xyz',
description = 'Asynchronous Pokemon API lib',
version = '1.3.2',
version = '1.3.3',
url = 'https://github.com/Noctem/aiopogo',
packages = find_packages(),
install_requires = [
Expand Down

0 comments on commit 06ec484

Please sign in to comment.