All right.
So our initial functionality works.
We are extending from the area we pass in the code and we're good to go.
Now, the problem is that as you were working on the API, there are multiple errors that are pretty
common.
So four hundred is one of them.
Then we also have one for not found, then we have for authentication and hopefully you see where I'm
going so hard coding.
This is probably not the best approach.
So what we could do instead?
Well, I could leave the custom API here and then just set up a few more classes that extend from this
one.
And in each class, we could heart code the status code and then we'll know that, let's say, for bad
request error, which status code is always going to be four hundred four, not founder.
It's going to be four or four.
And hopefully this makes sense.
So let's try this where I'm going to remove the status code for now.
And since I will use it, not going to delete it is going to remove it from custom API error and then
I'm going to create another class.
And yes, before you ask in the next video, we will refactor everything into a separate folder with
files and in the and all that cool stuff, but not for now.
So let's go here with class, and let's come up with the name so bad request.
And are really up to you, but I like to years the explicit name, so I know what is happening in this
case, I'm extending from the custom API, everyone.
OK, so and then pretty much the code is the same.
So take this or use the super Oh, here's the message.
And now I'm hard coding the status code one.
And what's going to happen right now?
Instead of using the custom API or one, we use the bat request one.
And again, what's really, really, really cool is that we only need to set up this ones and then we
can reuse it and all our project.
So I know that this might seem tedious, but actually in the long run, it's much better.
So what are we can do right now is just start out in the postman.
So it's centered, and now we still have 400 and we have the message.
And let's also set up one for not phone because it's going to be a little bit of time before we get
to on authenticator and not one will do right away in a separate file.
So what I want to do right now is again, copy and paste still within the controller and nonetheless
change the name, let's say, or here not.
Found error and instead of barrel quest, what is going to be the status code?
It's going to be four or four.
And when it comes to our constants we're looking for, we not found them again.
We're not going to use it right now.
But in general, I wanted to set it up right away so you can clearly see how it works.
So we're still extending from this one.
We still have the message all up, so we'll be able to pass it.
But in this case, the status code is not found.