Express - Error Handling

anonymous·2021년 9월 11일
0

How to handle/log Errors?

  • Express comes with a built-in error handler, which takes care of any remaining errors that might be encountered in the app
  • Errors are handled by one or more special middleware functions that have four arguments

Hello Error

app.use(function(err, req, res, next) {
  console.error(err.stack);
  res.status(500).send('Something broke!');
});

REF

https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/Introduction

profile
기술블로거입니다

0개의 댓글