Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle bad auth/ip case better #2

Open
posborne opened this issue Jun 2, 2015 · 0 comments
Open

Handle bad auth/ip case better #2

posborne opened this issue Jun 2, 2015 · 0 comments

Comments

@posborne
Copy link
Contributor

posborne commented Jun 2, 2015

In the case that the stored IP address or credentials are invalid, the CLI command currently produces somewhat unsavory output:

For an invalid IP address:

$ wva get /
Traceback (most recent call last):
  File "/home/posborne/.local/bin/wva", line 9, in <module>
    load_entry_point('wva==0.1.0', 'console_scripts', 'wva')()
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/wva/cli.py", line 552, in main
    cli(auto_envvar_prefix="WVA")
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/click/core.py", line 610, in __call__
    return self.main(*args, **kwargs)
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/click/core.py", line 590, in main
    rv = self.invoke(ctx)
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/click/core.py", line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/click/core.py", line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/wva/cli.py", line 196, in get
    cli_pprint(http_client.get(uri))
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/wva/http_client.py", line 135, in get
    return self.request("GET", uri, **kwargs)
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/wva/http_client.py", line 113, in request
    response = self.raw_request(method, uri, **kwargs)
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/wva/http_client.py", line 95, in raw_request
    six.raise_from(WVAHttpRequestError(e), e)
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/six.py", line 692, in raise_from
    raise value
wva.exceptions.WVAHttpRequestError: ('Connection aborted.', error(113, 'No route to host'))

And for a credentials problem:

Traceback (most recent call last):
  File "/home/posborne/.local/bin/wva", line 9, in <module>
    load_entry_point('wva==0.1.0', 'console_scripts', 'wva')()
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/wva/cli.py", line 552, in main
    cli(auto_envvar_prefix="WVA")
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/click/core.py", line 610, in __call__
    return self.main(*args, **kwargs)
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/click/core.py", line 590, in main
    rv = self.invoke(ctx)
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/click/core.py", line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/click/core.py", line 936, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/click/core.py", line 782, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/click/core.py", line 416, in invoke
    return callback(*args, **kwargs)
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/wva/cli.py", line 541, in authorize
    http_client.put(authorized_keys_uri, authorized_key_contents)
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/wva/http_client.py", line 162, in put
    return self.request("PUT", uri, data=data, **kwargs)
  File "/home/posborne/.local/venvs/wva/local/lib/python2.7/site-packages/wva/http_client.py", line 116, in request
    raise exception_class(response)
wva.exceptions.WVAHttpUnauthorizedError: Unexpected HTTP status 401 'WVAHttpUnauthorizedError'

In the case of an HTTP exception, a stack trace seems suboptimal. In addition, it would be nice to give hints to the user as to what may have gone wrong and what can be done to fix it. For both of these cases, telling the user that runngin wva cliconfig clear would be very helpful information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant