javascript - Pass err into express.js Router, Node.js -


can err passed express.js router?

there no answer in express.js documentation related express middleware, routers, , error handling (i can't post links due lack of reputation).

i thoroughly searched stackoverflow , couldn't find answer.

i google searched pretty thoroughly, , couldn't find answer.

example:

app.js

var express = require('express'); var myrouter = require('./myrouter.js'); var app = express();  app.use(function(req, res, next){   console.log('about call next("someerror")';   next('someerror'); }); app.use(myrouter); app.use(function (err, req, res, next){   console.log('handling error in main , err is:');   console.log(err); }); 

myrouter.js

var express = require('express');  var myrtr = module.exports = express.router();  myrtr.use(function(err, req, res, next){   console.log('handling error in myrouter.js');   next('anothererror'); }); 

i did testing express version 4.12.2.

the answer no.

the above case print:

about call next("someerror"); handling err in main , err is: someerror 

note: did more testing on wrote in above question, did not include sake of brevity.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -