Fix exception handling
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
bd529fddda
commit
8b2193af9b
@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
from functools import wraps
|
||||||
|
|
||||||
class Error(Exception):
|
class Error(Exception):
|
||||||
"""Base class for exceptions in this module."""
|
"""Base class for exceptions in this module."""
|
||||||
@ -15,12 +16,13 @@ class ApiInvalidResponseError(Error):
|
|||||||
class ConnectionTimeoutError(Error):
|
class ConnectionTimeoutError(Error):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def exception_handler(func):
|
def exception_handler(fn):
|
||||||
def inner_function(*args, **kwargs):
|
@wraps(fn)
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
try:
|
try:
|
||||||
func(*args, **kwargs)
|
fn(*args, **kwargs)
|
||||||
except Error:
|
except Error:
|
||||||
logger = logging.getLogger('')
|
logger = logging.getLogger('')
|
||||||
logger.exception("Internal error occur")
|
logger.exception("Internal error occur")
|
||||||
return inner_function
|
return wrapper
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user