Now that we have our CRUD operations, we should check that basic functionality works as expected. In this case, we want to ensure we correctly handle 404 errors. Let's look at the default way:

We can do better than this.
Correctly Handling 404 Error
We tried to load a category with the ID of 123 with our first test but got a long message. This was because we have APP_DEBUG=true in our .env file. We can change this to APP_DEBUG=false to see what we would get in a production environment:

I guess here it is much better to return
response()->json(['message' => '...'], 404)Since by default, it will return 200 code, that typically means "Ok", that might be misleading. And I know from experience that detecting errors by error text is pain in the arse, however when you receive 404, then there is no any misunderstanding here.You are right! I completely missed this case, where we override the status code (thought it was automatic in this case)
Okay, I have taken another look at it seems - that I haven't missed it! It's at the end (scroll needed) :)
Oh, my bad, FF didn't show me the scrolling at first. Sorry :)