+
+# Wrap Exception decorator
+def get_decorator(errors=(OSError, TimeoutError), wrap_into=Exception):
+ def decorator(func):
+ def w_func(*args, **kwargs):
+ try:
+ return func(*args, **kwargs)
+ except errors as err:
+ strerr = str(err)
+ if hasattr(err, 'strerror'):
+ if err.strerror:
+ strerr = err.strerror
+ raise wrap_into(strerr) from err
+ return w_func
+ return decorator
+