vercel / next-learn

Learn Next.js Starter Code
https://next-learn-dashboard.vercel.sh/
MIT License
3.71k stars 1.9k forks source link

Generic errors doesn't work along with 404 errors #662

Open angel-luis opened 5 months ago

angel-luis commented 5 months ago

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

nirajanach commented 5 months ago

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.