next-learn
next-learn copied to clipboard
Generic errors doesn't work along with 404 errors
After complete the part of Handling all errors with error.tsx, if you follow the instructions of Handling 404 errors with the notFound function, you won't get any 404 page.
This is because, the docs says that this line will return an empty array:
console.log(invoice); // Invoice is an empty array []
But when the UUID doesn't exist, it throws an errors instead an empty array.
I've downloaded the template the last week so everything should be updated.
Link
https://nextjs.org/learn/dashboard-app/error-handling
Yes the issue still persists as of today,
I logged on console just before notFound() in invoices/[id]/edit/page.tsx and it logged an empty array and the 404 error page rendered as it supposed to be.
if (!invoice) { console.log('error'); notFound(); }
I am not sure how it worked but it did for me.
PS you can remove the console log afterwards and the page stays there.