Answer the question
In order to leave comments, you need to log in
How to write a callback with error handling?
How can I write error handling code?
It seemed to me that this is how most functions are written in node, but ! new Error throws false
Why and how is it done in modules?
function func(err, data, cb) {
if(!err) {
cb(data);
} else {
console.log(err);
}
}
setTimeout(func.bind(null, new Error('error'), 'hello world', (data) => {
console.log(data);
}), 3000);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question