not-found.tsx not catching not found errors
Unanswered
Southeastern blueberry bee posted this in #help-forum
Southeastern blueberry beeOP
i have a not-found.tsx file in a dynamic route but it doesn't seem to catch the notFound() calls, it falls back the the previous error.tsx handler
31 Replies
Southeastern blueberry beeOP
and it also shows the NEXT_NOT_FOUND message that is from the notFound call
so im not sure why it would't work
also is there a way to enable errors to be visible in prod too? i don't want the "security feature" that next gives for errors
@Southeastern blueberry bee and it also shows the NEXT_NOT_FOUND message that is from the notFound call
throwing that error is just how notFound and redirect works, if you have a try catch, you should not have them inside or rethrow them
@riský throwing that error is just how notFound and redirect works, if you have a try catch, you should not have them inside or rethrow them
Southeastern blueberry beeOP
In my route I do something like
async function MyPage(){
...
if(response.status === 404){
return notFound()
}
...
}I don't catch the error elsewhere
o.O
and you on latest version right?
Southeastern blueberry beeOP
Yes
ok, i might look into this a bit more later... seems odd
@Southeastern blueberry bee i have a not-found.tsx file in a dynamic route but it doesn't seem to catch the notFound() calls, it falls back the the previous error.tsx handler
Southeastern blueberry beeOP
To make this work I had to move the not-found to the parent folder (courses) and it caught the not found, but, in a segment route which is completely different from this one, I have the exact same situation with a not found inside a dynamic route, and that one catches the not found in that segment as I expected
It doesn't make any sense
Error handling in next is really painful xD
i haven't played with error.tsx much yet ðŸ˜
@riský i haven't played with error.tsx much yet ðŸ˜
Southeastern blueberry beeOP
It's completely utterly useless
😢
Southeastern blueberry beeOP
Because you don't get the error that was thrown
So what are you gonna do with the error.tsx page? Write a "oopsie woopsie thewe was an ewwow"? The only context it gives you is that "there was an error" yeah thanks lmao
yeah its just meant to give a better screen for error times... but idk
@riský ok, i might look into this a bit more later... seems odd
Southeastern blueberry beeOP
Let me know if you find something
I guess I'll have to implement my own error component that returns a 200 status!
Since you can't override the status code of the response
@Southeastern blueberry bee I guess I'll have to implement my own error component that returns a 200 status!
i wonder if middleware can be abused ngl
@riský i wonder if middleware can be abused ngl
Southeastern blueberry beeOP
Middlewares are a pain to handle, you need to keep track of so many more things at that point
yeah
Southeastern blueberry beeOP
But I might try
also does redirect work, or does error take that too
Southeastern blueberry beeOP
I'm just annoyed that it feels like they are not considering basic use cases of a framework, it really feels like the app router was made for static websites
@riský also does redirect work, or does error take that too
Southeastern blueberry beeOP
I'm not on pc rn, I'm heading to bed, I'll check tomorrow
This is incredible