Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up

Which of these is the correct way to handle errors in an async Express 4 route handler?

  1. A Rely on Express to catch the rejection automatically
  2. B Wrap the handler so rejections are passed to next(err)
  3. C Use process.on('uncaughtException')
  4. D Return the error as a string
Answer

Wrap the handler so rejections are passed to next(err)

Express 4 does not catch rejected promises from async handlers, so the request hangs. Express 5 handles this natively.

All NodeJS MCQs

Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up as