Commit 2deb99c5 authored by Maël Kervella's avatar Maël Kervella

Add logging everywhere

parent 5b4523c7
from .re2oapi.client import Re2oAPIClient
from .re2oapi import exceptions
__all__ = ['Re2oAPIClient', 'exceptions']
from .re2oapi import *
from .client import Re2oAPIClient
from . import exceptions
__all__ = ['Re2oAPIClient', 'exceptions']
This diff is collapsed.
......@@ -113,13 +113,19 @@ def get_names():
return urls.keys()
def get_endpoint_for(name, **kwargs):
def get_endpoint_for(name, logger=None, **kwargs):
try:
url=urls[name]
except KeyError as e:
raise exceptions.URLNameDoesNotExists(name)
except KeyError:
e = exceptions.URLNameDoesNotExists(name)
if logger is not None:
logger.warning(e)
raise e
else:
try:
return url.format_map(kwargs)
except KeyError as e:
raise exceptions.URLParameterMissing(e)
e = exceptions.URLParameterMissing(name, e)
if logger is not None:
logger.warning(e)
raise e
......@@ -12,7 +12,7 @@ class URLNameDoesNotExists(APIClientGenericError):
class URLParameterMissing(APIClientGenericError):
template = "The url named '{}' require the parameter '{}' to be built."
template = "The url named '{}' requires the parameter {} to be built."
class InvalidCredentials(APIClientGenericError):
......@@ -22,9 +22,14 @@ class InvalidCredentials(APIClientGenericError):
class PermissionDenied(APIClientGenericError):
template = "The {} request to '{}' was denied for {}."
class TokenFileNotFound(APIClientGenericError):
template = "Token file at {} not found."
class TokenFileNotReadable(APIClientGenericError):
template = "Token file at {} is not a JSON readable file."
class TokenNotInTokenFile(APIClientGenericError):
template = "Token for {}@{} not found in token file ({})."
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment