Socket onerror callback not honored #1306
Replies: 3 comments
-
Posted at 2019-03-22 by @gfwilliams That's interesting - that behaviour is expected though. The error callback will get called in case of connection errors, but not for an error like that which is caused by a call on the socket. While it makes sense to have it behave the same as Node.js, I'd say the current behaviour is actually pretty useful - it really helps to have a stack trace from the offending line of code. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-03-23 by Steffen Wouldn't the same trace information be in the error callback? The advantage of no exception thrown is that you attach the callback once, while one has to do try/catch in all places now. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-03-25 by @gfwilliams
Unfortunately not - you just get a string describing the error as a parameter, but you have no idea where in the program it came from. Understood about the try..catch though - it's annoying having to do it. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2019-03-21 by Steffen
Socket instances don't seem to use the attached 'error' listener on error:
Is this expected behaviour?
I'm asking because in NodeJS, when an error listener is attached, no exception is thrown but the listener called (with the exception message) instead. If Espruino did the same, the last line should read like this:
EEE Error: This socket is closed. ...
(EEE because the listener prints it, then the error.)Beta Was this translation helpful? Give feedback.
All reactions