-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: emit an Error object upon middleware error
This commit restores the ability to send additional data in the middleware functions, which was removed during the rewrite to Typescript ([1]). The only difference with the previous implementation is that the client will now emit a "connect_error" (previously, "error") event with an actual Error object, with both the message and an optional "data" attribute. ```js // server-side io.use((socket, next) => { const err = new Error("not authorized"); err.data = { content: "Please retry later" }; next(err); }); // client-side socket.on("connect_error", err => { console.log(err.message); // not authorized console.log(err.data.content); // Please retry later }); ``` [1]: a5581a9
- Loading branch information
1 parent
aa7574f
commit 54bf4a4
Showing
4 changed files
with
45 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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