Commit 3a7221a6 authored by Joshua Tauberer's avatar Joshua Tauberer

handle errors in management API calls properly

see #118
parent 86ec0f6d
......@@ -11,7 +11,12 @@ def mgmt(cmd, data=None):
try:
response = urllib.request.urlopen(req)
except urllib.error.HTTPError as e:
print(e.read().decode('utf8'))
if e.code == 401:
print("The management daemon refused access. The API key file may be out of sync. Try 'service mailinabox restart'.", file=sys.stderr)
elif hasattr(e, 'read'):
print(e.read().decode('utf8'), file=sys.stderr)
else:
print(e, file=sys.stderr)
sys.exit(1)
return response.read().decode('utf8')
......
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