Skip to content

Commit

Permalink
Improve exception checking per review
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsca authored and lolwww committed Aug 19, 2020
1 parent c603cbf commit 024d20d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/charms/layer/openstack.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import binascii
import json
import re
import os
Expand Down Expand Up @@ -82,8 +83,13 @@ def get_credentials():
_creds_data = b64decode(config['credentials']).decode('utf8')
_creds_data = json.loads(_creds_data)
_merge_if_set(creds_data, _normalize_creds(_creds_data))
except Exception as e:
if str(e).startswith('unsupported auth-type'):
except (ValueError,
TypeError,
binascii.Error,
json.JSONDecodeError,
UnicodeDecodeError) as e:
if isinstance(e, ValueError) and \
str(e).startswith('unsupported auth-type'):
raise # handled below
log_err('Invalid value for credentials config\n{}',
format_exc())
Expand Down

0 comments on commit 024d20d

Please sign in to comment.