diff --git a/redcliff/cli.py b/redcliff/cli.py index 126e97e..755701b 100644 --- a/redcliff/cli.py +++ b/redcliff/cli.py @@ -2,6 +2,7 @@ import argparse +from . import api from .commands import dispatch, choices from .config import get_config from .utils import merge, error @@ -41,7 +42,11 @@ def main(): error('fatal: base_url and api_key are required') return 1 - return dispatch(cmd, cmd_args, merged_conf) + try: + return dispatch(cmd, cmd_args, merged_conf) + except api.AuthError: + error('fatal: authentication error') + return 1 if __name__ == '__main__': diff --git a/redcliff/commands/list.py b/redcliff/commands/list.py index fe4fed6..514541f 100644 --- a/redcliff/commands/list.py +++ b/redcliff/commands/list.py @@ -44,11 +44,8 @@ def run(argv, conf): try: data = api.issues.list(args, conf) - except api.AuthError: - error('fatal: authentication error') - return 1 except: - error('fatal: API error') + error('fatal: API error while gettings issues list') raise else: renderer.issues.as_table(data) diff --git a/redcliff/commands/update.py b/redcliff/commands/update.py index d256e6d..7496282 100644 --- a/redcliff/commands/update.py +++ b/redcliff/commands/update.py @@ -13,7 +13,11 @@ def run(argv, conf): args = vars(parser.parse_args(argv)) if args['status']: - status = api.statuses.by_name(args.pop('status'), conf) + try: + status = api.statuses.by_name(args.pop('status'), conf) + except: + error('fatal: API error while getting status by name') + raise if status: args['status_id'] = status['id'] else: @@ -22,11 +26,8 @@ def run(argv, conf): try: api.issues.update(args, conf) - except api.AuthError: - error('fatal: authentication error') - return 1 except: - error('fatal: API error') + error('fatal: API error while updating') raise else: success('Successfully updated.')