javascript - Use named function to catch errors in promises? -


i'm trying this:

var error = (reason) => {         console.log(reason);     };  //actually other promise promise.resolve()     .catch(error())     .then(render(req, res)); 

how can pass reason error function?

you have use catch(error) instead of catch(error()).

the catch method expects function argument. add named function itself, type error. if type error(), method executed first. result, log "undefined" and, function not return anything, evaluated "undefined" well. call catch(undefined).


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -