Skip to content

Commit

Permalink
make action server connection error message more descriptive (#11123)
Browse files Browse the repository at this point in the history
* make action server connection error message more descriptive
  • Loading branch information
indam23 authored May 17, 2022
1 parent 0dd0b71 commit bc2b1cb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions changelog/11123.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make the exception message raised when the action server is unreachable more descriptive.
16 changes: 11 additions & 5 deletions rasa/core/actions/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,15 +762,21 @@ async def run(
logger.error(exception.message)
raise exception
else:
raise RasaException("Failed to execute custom action.") from e
raise RasaException(
f"Failed to execute custom action '{self.name()}'"
) from e

except aiohttp.ClientConnectionError as e:
logger.error(
"Failed to run custom action '{}'. Couldn't connect "
"to the server at '{}'. Is the server running? "
"Error: {}".format(self.name(), self.action_endpoint.url, e)
f"Failed to run custom action '{self.name()}'. Couldn't connect "
f"to the server at '{self.action_endpoint.url}'. "
f"Is the server running? "
f"Error: {e}"
)
raise RasaException(
f"Failed to execute custom action '{self.name()}'. Couldn't connect "
f"to the server at '{self.action_endpoint.url}."
)
raise RasaException("Failed to execute custom action.")

except aiohttp.ClientError as e:
# not all errors have a status attribute, but
Expand Down
4 changes: 2 additions & 2 deletions tests/core/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ async def test_remote_action_endpoint_not_running(

with pytest.raises(Exception) as execinfo:
await remote_action.run(default_channel, default_nlg, default_tracker, domain)
assert "Failed to execute custom action." in str(execinfo.value)
assert "Failed to execute custom action" in str(execinfo.value)


async def test_remote_action_endpoint_responds_500(
Expand All @@ -564,7 +564,7 @@ async def test_remote_action_endpoint_responds_500(
await remote_action.run(
default_channel, default_nlg, default_tracker, domain
)
assert "Failed to execute custom action." in str(execinfo.value)
assert "Failed to execute custom action" in str(execinfo.value)


async def test_remote_action_endpoint_responds_400(
Expand Down

0 comments on commit bc2b1cb

Please sign in to comment.