[PR #57] [MERGED] print better error message if TermPair server is not running #66

Closed
opened 2026-03-03 01:21:28 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/cs01/termpair/pull/57
Author: @cs01
Created: 7/11/2021
Status: Merged
Merged: 7/11/2021
Merged by: @cs01

Base: masterHead: cs01/improve-error-message


📝 Commits (1)

  • 22c038f print better error message if TermPair server is not running

📊 Changes

4 files changed (+50 additions, -33 deletions)

View changed files

📝 .github/PULL_REQUEST_TEMPLATE.md (+1 -1)
📝 CHANGELOG.md (+1 -0)
📝 termpair/main.py (+31 -8)
📝 termpair/share.py (+17 -24)

📄 Description

  • I have added an entry to docs/changelog.md

Summary of changes

Make error message more clear when server isn't running.

Before

Traceback (most recent call last):
  File "/home/csmith/git/termpair/.nox/broadcast/bin/termpair", line 33, in <module>
    sys.exit(load_entry_point('termpair', 'console_scripts', 'termpair')())
  File "/home/csmith/git/termpair/termpair/main.py", line 109, in main
    asyncio.get_event_loop().run_until_complete(
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/home/csmith/git/termpair/termpair/share.py", line 231, in broadcast_terminal
    async with websockets.connect(ws_endpoint, ssl=ssl_context) as ws:
  File "/home/csmith/git/termpair/.nox/broadcast/lib/python3.8/site-packages/websockets/legacy/client.py", line 604, in __aenter__
    return await self
  File "/home/csmith/git/termpair/.nox/broadcast/lib/python3.8/site-packages/websockets/legacy/client.py", line 622, in __await_impl__
    transport, protocol = await self._create_connection()
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1025, in create_connection
    raise exceptions[0]
  File "/usr/lib/python3.8/asyncio/base_events.py", line 1010, in create_connection
    sock = await self._connect_sock(
  File "/usr/lib/python3.8/asyncio/base_events.py", line 924, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/lib/python3.8/asyncio/selector_events.py", line 496, in sock_connect
    return await fut
  File "/usr/lib/python3.8/asyncio/selector_events.py", line 528, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 8000)

After

Connection was refused. Is the TermPair server running on the host and port specified?
[Errno 111] Connect call failed ('127.0.0.1', 8000)

I also added a message to report bugs if a different error is thrown with a little prefix to the stacktrace:

TermPair encountered an error. If you think this is a bug, it can be reported at https://github.com/cs01/termpair/issues

Traceback (most recent call last):
  File "/home/csmith/git/termpair/termpair/main.py", line 140, in main
    f
NameError: name 'f' is not defined

Test plan

Tested by running

> nox -s broadcast 
nox > Running session broadcast
nox > Re-using existing virtual environment at .nox/broadcast.
Note: Frontend must be built for this to work
nox > python -m pip install -e .
nox > termpair share
Connection was refused. Is the TermPair server running on the host and port specified?
[Errno 111] Connect call failed ('127.0.0.1', 8000)

fixes #37


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cs01/termpair/pull/57 **Author:** [@cs01](https://github.com/cs01) **Created:** 7/11/2021 **Status:** ✅ Merged **Merged:** 7/11/2021 **Merged by:** [@cs01](https://github.com/cs01) **Base:** `master` ← **Head:** `cs01/improve-error-message` --- ### 📝 Commits (1) - [`22c038f`](https://github.com/cs01/termpair/commit/22c038f7b5f6a45f6ab7068416ee44c3071de6f0) print better error message if TermPair server is not running ### 📊 Changes **4 files changed** (+50 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `.github/PULL_REQUEST_TEMPLATE.md` (+1 -1) 📝 `CHANGELOG.md` (+1 -0) 📝 `termpair/main.py` (+31 -8) 📝 `termpair/share.py` (+17 -24) </details> ### 📄 Description <!-- add an 'x' in the brackets below --> * [x] I have added an entry to `docs/changelog.md` ## Summary of changes Make error message more clear when server isn't running. Before ``` Traceback (most recent call last): File "/home/csmith/git/termpair/.nox/broadcast/bin/termpair", line 33, in <module> sys.exit(load_entry_point('termpair', 'console_scripts', 'termpair')()) File "/home/csmith/git/termpair/termpair/main.py", line 109, in main asyncio.get_event_loop().run_until_complete( File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete return future.result() File "/home/csmith/git/termpair/termpair/share.py", line 231, in broadcast_terminal async with websockets.connect(ws_endpoint, ssl=ssl_context) as ws: File "/home/csmith/git/termpair/.nox/broadcast/lib/python3.8/site-packages/websockets/legacy/client.py", line 604, in __aenter__ return await self File "/home/csmith/git/termpair/.nox/broadcast/lib/python3.8/site-packages/websockets/legacy/client.py", line 622, in __await_impl__ transport, protocol = await self._create_connection() File "/usr/lib/python3.8/asyncio/base_events.py", line 1025, in create_connection raise exceptions[0] File "/usr/lib/python3.8/asyncio/base_events.py", line 1010, in create_connection sock = await self._connect_sock( File "/usr/lib/python3.8/asyncio/base_events.py", line 924, in _connect_sock await self.sock_connect(sock, address) File "/usr/lib/python3.8/asyncio/selector_events.py", line 496, in sock_connect return await fut File "/usr/lib/python3.8/asyncio/selector_events.py", line 528, in _sock_connect_cb raise OSError(err, f'Connect call failed {address}') ConnectionRefusedError: [Errno 111] Connect call failed ('127.0.0.1', 8000) ``` After ``` Connection was refused. Is the TermPair server running on the host and port specified? [Errno 111] Connect call failed ('127.0.0.1', 8000) ``` I also added a message to report bugs if a different error is thrown with a little prefix to the stacktrace: ``` TermPair encountered an error. If you think this is a bug, it can be reported at https://github.com/cs01/termpair/issues Traceback (most recent call last): File "/home/csmith/git/termpair/termpair/main.py", line 140, in main f NameError: name 'f' is not defined ``` ## Test plan <!-- provide evidence of testing, preferably with command(s) that can be copy+pasted by others --> Tested by running ``` > nox -s broadcast nox > Running session broadcast nox > Re-using existing virtual environment at .nox/broadcast. Note: Frontend must be built for this to work nox > python -m pip install -e . nox > termpair share Connection was refused. Is the TermPair server running on the host and port specified? [Errno 111] Connect call failed ('127.0.0.1', 8000) ``` fixes #37 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-03 01:21:28 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/termpair#66
No description provided.