Pass the `Error` via _callback_ or re`throw`?

Authentication with Socket.IO challenge raised a question for me. Particularly this one function in snippet.

function onAuthorizeFail(data, message, error, accept) {
  if (error) throw new Error(message);
  console.log('failed connection to', message);
  accept(null, false);

Previously curriculum said that the first argument of CB is conventionally for passing errors. And through examples usually it were demonstrated. And the question is why in this case we rethrow the error and then also call CB-function with null parameter for error-argument?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.