Merge pull request #419 from blockstack/better-api-auth-errors

better errors from the CLI when it fails to authenticate with the API service
This commit is contained in:
Jude Nelson
2017-05-09 14:53:38 -05:00
committed by GitHub
2 changed files with 10 additions and 0 deletions

View File

@@ -724,6 +724,9 @@ def cli_get_registrar_info(args, config_path=CONFIG_PATH, queues=None):
log.error("Failed to contact Blockstack daemon")
return {'error': 'Failed to contact blockstack daemon. Please ensure that it is running with the `api` command.'}
if 'error' in current_state:
return current_state
queue_types = dict( [(queue_name, []) for queue_name in queues] )
def format_queue_entry(entry):
@@ -846,6 +849,8 @@ def get_server_info(config_path=CONFIG_PATH, get_local_info=False):
queue_info = cli_get_registrar_info(None, config_path=config_path)
if 'error' not in queue_info:
result['queues'] = queue_info
else:
return queue_info
return result

View File

@@ -3553,6 +3553,11 @@ class BlockstackAPIEndpointClient(object):
except:
resp = {'error': 'No JSON response', 'http_status': req.status_code}
if req.status_code == 403:
resp['error'] = ('Authentication to API service failed. Are you ' +
'using the correct API password or do you need to pass the ' +
'correct one with --api_password ?')
del resp['http_status']
return resp