hoangvvo / nextjs-mongodb-app

A Next.js and MongoDB web application, designed with simplicity for learning and real-world applicability in mind.
https://nextjs-mongodb.now.sh/
MIT License
1.54k stars 289 forks source link

Handling errors that are thrown in onNoMatch handler #77

Closed edshav closed 4 years ago

edshav commented 4 years ago

options.onError function could catch errors that are thrown in options.onNoMatch handler. So we could explicit throw custom error in onNoMatch function. As a result, all errors will be processed in one place.

import { NotFoundError } from 'errors/not-found-error';

export const onNoMatch = (): void => {
  throw new NotFoundError();
};
edshav commented 4 years ago

Wrong target repo. I'm sorry.