gigalixir / gigalixir-cli

MIT License
52 stars 45 forks source link

Don't dump the stack when Rollbar cannot be reached #87

Open micahbf opened 3 years ago

micahbf commented 3 years ago

I use a DNS-level blocker for ads and trackers. Because of this, api.rollbar.com does not resolve on my computer.

The issue is, whenever I trigger an error with the CLI, it dumps a huge, ugly Python stack trace. (See below).

It would be nice if the CLI would swallow errors raised from the error reporting service.

Additionally, it could be nice to make the error reporting opt-in, or at least opt-out-able.

$ gigalixir ps:remote_console -a foo
You don't have any ssh keys yet. See `gigalixir account:ssh_keys:add --help`
Exception while posting item ConnectionError(MaxRetryError("HTTPSConnectionPool(host='api.rollbar.com', port=443): Max retries exceeded with url: /api/1/item/ (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x102c75490>: Failed to establish a new connection: [Errno 61] Connection refused'))"))
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.9/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/opt/homebrew/lib/python3.9/site-packages/urllib3/util/connection.py", line 96, in create_connection
    raise err
  File "/opt/homebrew/lib/python3.9/site-packages/urllib3/util/connection.py", line 86, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.9/site-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/opt/homebrew/lib/python3.9/site-packages/urllib3/connectionpool.py", line 382, in _make_request
    self._validate_conn(conn)
  File "/opt/homebrew/lib/python3.9/site-packages/urllib3/connectionpool.py", line 1010, in _validate_conn
    conn.connect()
  File "/opt/homebrew/lib/python3.9/site-packages/urllib3/connection.py", line 358, in connect
    conn = self._new_conn()
  File "/opt/homebrew/lib/python3.9/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x102c75490>: Failed to establish a new connection: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.9/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/opt/homebrew/lib/python3.9/site-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/opt/homebrew/lib/python3.9/site-packages/urllib3/util/retry.py", line 574, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.rollbar.com', port=443): Max retries exceeded with url: /api/1/item/ (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x102c75490>: Failed to establish a new connection: [Errno 61] Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.9/site-packages/rollbar/__init__.py", line 1497, in _send_payload
    _post_api('item/', payload_str, access_token=access_token)
  File "/opt/homebrew/lib/python3.9/site-packages/rollbar/__init__.py", line 1545, in _post_api
    resp = transport.post(url,
  File "/opt/homebrew/lib/python3.9/site-packages/rollbar/lib/transport.py", line 44, in post
    return _session().post(*args, proxies=proxies, **kw)
  File "/opt/homebrew/lib/python3.9/site-packages/requests/sessions.py", line 590, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/opt/homebrew/lib/python3.9/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.rollbar.com', port=443): Max retries exceeded with url: /api/1/item/ (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x102c75490>: Failed to establish a new connection: [Errno 61] Connection refused'))
jesseshieh commented 3 years ago

Thanks for the feedback! I think these are both great ideas. I can't promise when we will have time to implement them, but I'd be happy to approve a pull request if you have time to put it together.

micahbf commented 3 years ago

Thanks, but I'm not much of a python guy. Just swallowing the exceptions would be a big improvement though, right now it is fairly unpleasant to use.