评论

收藏

[JavaScript] error handling in Nodejs

开发技术 开发技术 发布于:2021-07-16 20:30 | 阅读数:241 | 评论:0

If I simply throw the exception:
app.get('/error', (request, response) => {  
  throw new Error('Jerry oops')
});
Then:
Error: Jerry oops
at app.get (C:\Code\git\practice\nodejs\index.js:55:9)
at Layer.handle [as handle_request] (C:\Code\git\practice\nodejs\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Code\git\practice\nodejs\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (C:\Code\git\practice\nodejs\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (C:\Code\git\practice\nodejs\node_modules\express\lib\router\layer.js:95:5)
at C:\Code\git\practice\nodejs\node_modules\express\lib\router\index.js:281:22
at Function.process_params (C:\Code\git\practice\nodejs\node_modules\express\lib\router\index.js:335:12)
at next (C:\Code\git\practice\nodejs\node_modules\express\lib\router\index.js:275:10)
at app.use (C:\Code\git\practice\nodejs\index.js:45:3)
at Layer.handle [as handle_request] (C:\Code\git\practice\nodejs\node_modules\express\lib\router\layer.js:95:5)


关注下面的标签,发现更多相似文章