You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In server.js file, generateId errors are handled as the below:
this.generateId(req, function (err, id) {
if (err) {
sendErrorMessage(req, req.res, Server.errors.BAD_REQUEST);
return;
}
...
}
Because of generateId method can be overwritten by the user, it should be throw the error what the user sent.
My proposal:
this.generateId(req, function (err, id) {
if (err) {
sendErrorMessage(req, req.res, err);
return;
}
...
}
I could not decide this is the correct way to handle errors or not. Because, the user function might throws an error that designed by the user.
However, the error turns into a BAD_REQUEST error in the end.
On the other hand this is a part of socket.io and socket.io-client-java modules do not handle the error of BAD_REQUEST on any method (if I'm right).
For instance I throw different error codes on generateId method on different cases. Then I handle this error on client side (like invalidate_auth_token).
I use a workaround for this for now. I send error codes as socketId then I check the socketId value in a socket middleware. If socketId value is one of the error codes, then disconnect the connection and send the error code to the client.
The text was updated successfully, but these errors were encountered:
efkan
changed the title
A question about error handling method in server.js file
A proposal about error handling on a user defined function in server.js file
Nov 6, 2017
Current behaviour
In server.js file,
generateId
errors are handled as the below:Because of
generateId
method can be overwritten by the user, it should be throw the error what the user sent.My proposal:
I could not decide this is the correct way to handle errors or not. Because, the user function might throws an error that designed by the user.
However, the error turns into a
BAD_REQUEST
error in the end.On the other hand this is a part of
socket.io
andsocket.io-client-java
modules do not handle the error ofBAD_REQUEST
on any method (if I'm right).For instance I throw different error codes on
generateId
method on different cases. Then I handle this error on client side (like invalidate_auth_token).I use a workaround for this for now. I send error codes as socketId then I check the socketId value in a socket middleware. If socketId value is one of the error codes, then disconnect the connection and send the error code to the client.
The text was updated successfully, but these errors were encountered: