lumberjack-core icon indicating copy to clipboard operation
lumberjack-core copied to clipboard

How can I return a 404 Not Found error from my product controller?

Open kristiwr opened this issue 4 years ago • 1 comments

Hello, I'm trying to figure out the best way to return a 404 error from my product controller. This would happen when the product route matches but there is no product post matching the slug. I've looked through the documentation and some of the Lumberjack source code and haven't found a solution. What is the best way to return a 404 error from inside a controller?

kristiwr avatar May 26 '21 19:05 kristiwr

I found a solution in the view helper. Here's the code I used:

view('errors/404.twig', $context, 404);

It would be helpful if the procedure for returning a 404 were explained in the HTTP Responses section in the docs.

kristiwr avatar May 27 '21 16:05 kristiwr