[lua] Add error message param to onreceive handler#5476
Merged
dacap merged 1 commit intoOct 22, 2025
Conversation
Now script developer can define websocket's onreceive handlers with an additional parameter that holds error information when messages of type WebSocketMessageType.ERROR are received
aseprite-bot
left a comment
Collaborator
There was a problem hiding this comment.
clang-tidy made some suggestions
| ws->setOnMessageCallback([L, ws, onreceiveRef](const ix::WebSocketMessagePtr& msg) { | ||
| int msgType = (msg->binary ? MESSAGE_TYPE_BINARY : static_cast<int>(msg->type)); | ||
| std::string msgData = msg->str; | ||
| std::string msgError = msg->errorInfo.reason; |
Collaborator
There was a problem hiding this comment.
warning: variable 'msgError' of type 'std::string' (aka 'basic_string') can be declared 'const' [misc-const-correctness]
Suggested change
| std::string msgError = msg->errorInfo.reason; | |
| std::string const msgError = msg->errorInfo.reason; |
Member
|
I'll merge it as it is. It's a shame that the API design is not prepared for extensibility, i.e. just one "ev" argument with message type/data/error inside. I'll create a new issue to redesign the API in some way in the future. |
Member
Author
|
Yeah, that would be nice. It would break current scripts though. |
This was referenced Oct 22, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Now script developer can define websocket's onreceive handlers with an additional parameter that holds error information when messages of type WebSocketMessageType.ERROR are received
NOTE: This PR was not requested explicitly, but I saw the opportunity to add this while trying to debug a script that used websockets.