Skip to content

fix: clarify external error messages - #151

Open
ghassan-gaidi wants to merge 1 commit into
grammyjs:mainfrom
ghassan-gaidi:fix/clarify-external-error-messages
Open

fix: clarify external error messages#151
ghassan-gaidi wants to merge 1 commit into
grammyjs:mainfrom
ghassan-gaidi:fix/clarify-external-error-messages

Conversation

@ghassan-gaidi

Copy link
Copy Markdown

Improve two error messages to help users identify the root cause faster:

Changes

src/conversation.ts - wait() error message now explicitly mentions that Bot API calls must not be made inside external():

"Cannot wait for updates from inside external, or concurrently to it! Bot API calls (e.g. ctx.api.*, ctx.reply) must not be made inside external. First return your data from external and then resume update handling using wait calls."

src/state.ts - Bad replay error now shows both the expected and actual operation, plus a hint about the common cause:

"Bad replay, expected op '...' but got '...'. This usually means a Bot API call was made inside `conversation.external()` or the conversation was otherwise used incorrectly."

Closes #148

Improve error messages in conversation.external() to explicitly
mention Bot API calls as the likely root cause.

- wait() error: Added note that Bot API calls (ctx.api.*, ctx.reply,
  etc.) must not be made inside external().
- Bad replay error (state.ts): Added the actual op that was received
  alongside the expected op, plus a hint about the common cause.

Closes grammyjs#148
@KnorpelSenf

Copy link
Copy Markdown
Member

Did you try to reproduce these issues before you adjusted the error messages? I don't think that they're both caused by the same issue, so this seems weirdly off. Was this maybe fully AI-generated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clarify error: “Cannot wait for updates from inside external…” should mention Bot API calls

2 participants