Answer the question
In order to leave comments, you need to log in
Why should the error handling function, according to some kind of "programmer convention", take/return an error code as the first parameter, and not a message?
Why should the error handling function, according to some kind of "programmer convention", take/return an error code as the first parameter, and not a message?
In PHP for some reason throw new Expression($msg, $code);
It is clear that you often need to send more data along with the message, so it will become $msg, $data, $code, but the error code? why was it pushed forward?
Answer the question
In order to leave comments, you need to log in
Everything is very simple.
The callback function in a node takes a variable number of arguments. If a possible error is passed as the last argument, then for each API function it will be necessary to remember the actual number of arguments to the callback function in order to write the error to the required variable.
If you don't like it, use promises.
Judging by the number of signatories, I want to say one thing for sure, if on the forum the phrase "by agreement of programmers" is believed, extremely more people believe than if you say "I was thinking, why not do it ..." - apparently it works
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question