dynamist / phabfive

A command line tool to interact with Phabricator
Apache License 2.0
4 stars 2 forks source link

Wrap "name of service not known" exception in better exception #28

Open Grokzen opened 4 years ago

Grokzen commented 4 years ago

Environment

Steps to Reproduce

## When running this

$ phabfive diffusion list inactive

Traceback (most recent call last):
  File "/home/nn/.virtualenvs/phabfive-kOPdHCq0/bin/phabfive", line 11, in <module>
    load_entry_point('phabfive', 'console_scripts', 'phabfive')()
  File "/home/nn/code/phabfive/phabfive/cli.py", line 119, in cli_entrypoint
    run(cli_args, sub_args)
  File "/home/nn/code/phabfive/phabfive/cli.py", line 103, in run
    print(p.print_secret(p.get_secret(sub_args['<id>'])))
  File "/home/nn/code/phabfive/phabfive/passphrase.py", line 33, in get_secret
    response = self.phab.passphrase.query(ids=[ids], needSecrets=1)
  File "/home/nn/.virtualenvs/phabfive-kOPdHCq0/lib/python3.6/site-packages/phabricator/__init__.py", line 248, in __call__
    return self._request(**kwargs)
  File "/home/nn/.virtualenvs/phabfive-kOPdHCq0/lib/python3.6/site-packages/phabricator/__init__.py", line 308, in _request
    conn.request('POST', path, body, headers)
  File "/usr/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/usr/lib/python3.6/http/client.py", line 1392, in connect
    super().connect()
  File "/usr/lib/python3.6/http/client.py", line 936, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/lib/python3.6/socket.py", line 704, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/lib/python3.6/socket.py", line 745, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

Expected Behavior

A bettter and wrapped exception to be presented to the user.

Observed Behavior

A low level exception was raised to the user