mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-18 18:39:21 +02:00
More specific error returns
This commit is contained in:
parent
f22d72da4d
commit
a02d27aaec
2 changed files with 10 additions and 6 deletions
|
@ -62,15 +62,12 @@ class EPPLibWrapper:
|
|||
password=settings.SECRET_REGISTRY_KEY_PASSPHRASE,
|
||||
)
|
||||
)
|
||||
# prepare a context manager which will connect and login when invoked
|
||||
# (it will also logout and disconnect when the context manager exits)
|
||||
self._connect = Socket(self._client, self._login)
|
||||
options = {
|
||||
# Pool size
|
||||
"size": 10,
|
||||
# Which errors the pool should look out for
|
||||
"exc_classes": (LoginError, RegistryError,),
|
||||
# Should we ping the connection on occassion to keep it alive?
|
||||
# Should we ping the connection on occasion to keep it alive?
|
||||
"keepalive": None,
|
||||
}
|
||||
self._pool = EppConnectionPool(client=self._client, login=self._login, options=options)
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
import logging
|
||||
from geventconnpool import ConnectionPool
|
||||
from epplibwrapper import RegistryError
|
||||
from epplibwrapper.errors import LoginError
|
||||
from epplibwrapper.socket import Socket
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class EppConnectionPool(ConnectionPool):
|
||||
def __init__(self, client, login, options):
|
||||
# For storing shared credentials
|
||||
|
@ -13,8 +18,10 @@ class EppConnectionPool(ConnectionPool):
|
|||
try:
|
||||
connection = socket.connect()
|
||||
return connection
|
||||
except Exception as err:
|
||||
raise err
|
||||
except LoginError as err:
|
||||
message = "_new_connection failed to execute due to a registry login error."
|
||||
logger.warning(message, exc_info=True)
|
||||
raise RegistryError(message) from err
|
||||
|
||||
def _keepalive(self, connection):
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue