mandeep/Travis-Encrypt

Feature Request: Exception Handling When User/Repo Not Found

Opened this issue · 1 comments

Would like to work on exception handling when a user and/or repo is not found. Without the exception handling the user is presented with a trackback and the reason for the error is hard to read.

$ travis-encrypt no-one nothing
Password: 

Traceback (most recent call last):
  File "/home/user/Documents/Development/Travis-Encrypt/travis/encrypt.py", line 49, in retrieve_public_key
    return response.json()['key'].replace(' RSA ', ' ')
KeyError: 'key'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/.local/share/virtualenvs/Travis-Encrypt-Ark2TLtq/bin/travis-encrypt", line 11, in <module>
    load_entry_point('travis-encrypt', 'console_scripts', 'travis-encrypt')()
  File "/home/user/.local/share/virtualenvs/Travis-Encrypt-Ark2TLtq/lib/python3.7/site-packages/Click-7.0-py3.7.egg/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/user/.local/share/virtualenvs/Travis-Encrypt-Ark2TLtq/lib/python3.7/site-packages/Click-7.0-py3.7.egg/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/user/.local/share/virtualenvs/Travis-Encrypt-Ark2TLtq/lib/python3.7/site-packages/Click-7.0-py3.7.egg/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/user/.local/share/virtualenvs/Travis-Encrypt-Ark2TLtq/lib/python3.7/site-packages/Click-7.0-py3.7.egg/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/user/Documents/Development/Travis-Encrypt/travis/cli.py", line 68, in cli
    key = retrieve_public_key('{}/{}' .format(username, repository), url)
  File "/home/user/Documents/Development/Travis-Encrypt/travis/encrypt.py", line 52, in retrieve_public_key
    raise InvalidCredentialsError("Either the username: '{}' or the repository: '{}' does not exist. Please enter a valid username or repository name. The username and repository name are both case sensitive." .format(username, repository))
travis.encrypt.InvalidCredentialsError: Either the username: 'no-one' or the repository: 'nothing' does not exist. Please enter a valid username or repository name. The username and repository name are both case sensitive.