Skip to content

Commit

Permalink
No need to rewrap the HandlerError
Browse files Browse the repository at this point in the history
Signed-off-by: Aurélien Bompard <aurelien@bompard.org>
  • Loading branch information
abompard committed Apr 14, 2023
1 parent 1d0d4fb commit ff2c69f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 6 deletions.
2 changes: 0 additions & 2 deletions fmn/sender/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ async def _main(handler, consumer):
await asyncio.wait_for(handler.setup(), timeout=HANDLER_CONNECT_TIMEOUT)
except asyncio.exceptions.TimeoutError as e:
raise HandlerError(f"the handler could not connect in {HANDLER_CONNECT_TIMEOUT}s") from e
except HandlerError as e:
raise HandlerError(f"the handler could not connect: {e}") from e

# Shutdown in case of unexpected disconnections
shutdown_on_closed = asyncio.create_task(_shutdown(handler.closed, consumer))
Expand Down
2 changes: 1 addition & 1 deletion fmn/sender/irc.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async def connect(self, *args, **kwargs):
except ServerConnectionError as e:
message = e.args[0]
self.closed.set_result(message)
raise HandlerError(message) from e
raise HandlerError(f"the handler could not connect: {message}") from e

async def privmsg(self, *args, **kwargs):
# This is not async yet.
Expand Down
4 changes: 1 addition & 3 deletions tests/sender/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ def test_cli_handler_setup_error(config_file, mocked_handler, mocked_consumer):
result = runner.invoke(cli.main, ["-c", config_file])

assert result.exit_code == 1
expected = (
"Shutting down: exception caught\nError: the handler could not connect: dummy error\n"
)
expected = "Shutting down: exception caught\nError: dummy error\n"
assert result.output == expected
mocked_consumer.stop.assert_awaited_once_with()

Expand Down

0 comments on commit ff2c69f

Please sign in to comment.