mirror of
https://github.com/sprockets/sprockets.clients.dynamodb.git
synced 2024-11-23 11:19:54 +00:00
Handle more exception types
This commit is contained in:
parent
c2c26da23b
commit
a3f095553c
2 changed files with 11 additions and 2 deletions
|
@ -4,7 +4,7 @@ except ImportError as error:
|
|||
def DynamoDB(*args, **kwargs):
|
||||
raise error
|
||||
|
||||
version_info = (0, 3, 1)
|
||||
version_info = (0, 3, 2)
|
||||
__version__ = '.'.join(str(v) for v in version_info)
|
||||
|
||||
# Response constants
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import json
|
||||
import logging
|
||||
import os
|
||||
import select
|
||||
import socket
|
||||
import ssl
|
||||
|
||||
from tornado import concurrent, httpclient, ioloop
|
||||
import tornado_aws
|
||||
|
@ -10,7 +12,7 @@ from tornado_aws import exceptions as aws_exceptions
|
|||
from . import utils
|
||||
from . import exceptions
|
||||
|
||||
# Stub ConnectionError && ConnectionResetError for Python 2.7
|
||||
# Stub Python3 exceptions for Python 2.7
|
||||
try:
|
||||
ConnectionError
|
||||
except NameError:
|
||||
|
@ -20,6 +22,9 @@ except NameError:
|
|||
class ConnectionResetError(Exception):
|
||||
pass
|
||||
|
||||
class TimeoutError(Exception):
|
||||
pass
|
||||
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -121,6 +126,8 @@ class DynamoDB(object):
|
|||
response_reason = http_err.response.body
|
||||
future.set_exception(
|
||||
exceptions.RequestException(response_reason))
|
||||
except TimeoutError:
|
||||
future.set_exception(exceptions.TimeoutException())
|
||||
except Exception as exception:
|
||||
future.set_exception(exception)
|
||||
else:
|
||||
|
@ -140,6 +147,8 @@ class DynamoDB(object):
|
|||
except (ConnectionError,
|
||||
ConnectionResetError,
|
||||
OSError,
|
||||
select.error,
|
||||
ssl.socket_error,
|
||||
socket.gaierror) as error:
|
||||
future.set_exception(exceptions.RequestException(str(error)))
|
||||
except httpclient.HTTPError as err:
|
||||
|
|
Loading…
Reference in a new issue