def echo_errors(f):
"""
Decorator for subcommands, that will echo any known errors from Client.
"""
@wraps(f)
def wrapped(*args, **kwargs):
try:
return f(*args, **kwargs)
except dprclient.ConfigError as e:
echo('[ERROR]: %s \n\n'
'To enter configuration options please run:\n'
' dpmpy configure\n' % str(e))
sys.exit(1)
except requests.ConnectionError as e:
echo('[ERROR] %s\n' % repr(e))
echo('Network error. Please check your connection settings\n')
sys.exit(1)
except dprclient.HTTPStatusError as e:
echo('[ERROR] %s\n' % str(e.message))
sys.exit(1)
except dprclient.DpmException as e:
echo('[ERROR] %s\n' % str(e))
sys.exit(1)
return wrapped
评论列表
文章目录