Skip to content

Commit e43855e

Browse files
authored
Use ConfigException instead of UsageException (#167)
1 parent e9a022f commit e43855e

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

alertaclient/auth/utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from netrc import netrc
44
from urllib.parse import urlparse
55

6-
import click
6+
from alertaclient.exceptions import ConfigurationError
77

88
NETRC_FILE = os.path.join(os.environ['HOME'], '.netrc')
99

@@ -30,7 +30,7 @@ def save_token(endpoint, username, token):
3030
try:
3131
info = netrc(NETRC_FILE)
3232
except Exception as e:
33-
raise click.UsageError('{}'.format(e))
33+
raise ConfigurationError('{}'.format(e))
3434
info.hosts[machine(endpoint)] = (username, None, token)
3535
with open(NETRC_FILE, 'w') as f:
3636
f.write(dump_netrc(info))
@@ -40,13 +40,13 @@ def clear_token(endpoint):
4040
try:
4141
info = netrc(NETRC_FILE)
4242
except Exception as e:
43-
raise click.UsageError('{}'.format(e))
43+
raise ConfigurationError('{}'.format(e))
4444
try:
4545
del info.hosts[machine(endpoint)]
4646
with open(NETRC_FILE, 'w') as f:
4747
f.write(dump_netrc(info))
4848
except KeyError as e:
49-
raise click.UsageError('No credentials stored for {}'.format(e))
49+
raise ConfigurationError('No credentials stored for {}'.format(e))
5050

5151

5252
# See https://bugs.python.org/issue30806

0 commit comments

Comments
 (0)