1
00:00:00,120 --> 00:00:00,550
All right.

2
00:00:00,570 --> 00:00:02,760
So our initial functionality works.

3
00:00:03,960 --> 00:00:08,880
We are extending from the area we pass in the code and we're good to go.

4
00:00:09,740 --> 00:00:16,400
Now, the problem is that as you were working on the API, there are multiple errors that are pretty

5
00:00:16,400 --> 00:00:16,760
common.

6
00:00:17,450 --> 00:00:18,920
So four hundred is one of them.

7
00:00:19,370 --> 00:00:26,930
Then we also have one for not found, then we have for authentication and hopefully you see where I'm

8
00:00:26,930 --> 00:00:29,360
going so hard coding.

9
00:00:29,360 --> 00:00:32,180
This is probably not the best approach.

10
00:00:32,780 --> 00:00:34,470
So what we could do instead?

11
00:00:34,490 --> 00:00:42,140
Well, I could leave the custom API here and then just set up a few more classes that extend from this

12
00:00:42,140 --> 00:00:42,380
one.

13
00:00:43,040 --> 00:00:51,710
And in each class, we could heart code the status code and then we'll know that, let's say, for bad

14
00:00:51,710 --> 00:00:57,110
request error, which status code is always going to be four hundred four, not founder.

15
00:00:57,350 --> 00:00:58,520
It's going to be four or four.

16
00:00:58,940 --> 00:01:00,470
And hopefully this makes sense.

17
00:01:00,890 --> 00:01:04,940
So let's try this where I'm going to remove the status code for now.

18
00:01:05,360 --> 00:01:10,850
And since I will use it, not going to delete it is going to remove it from custom API error and then

19
00:01:10,850 --> 00:01:12,050
I'm going to create another class.

20
00:01:12,260 --> 00:01:21,170
And yes, before you ask in the next video, we will refactor everything into a separate folder with

21
00:01:21,170 --> 00:01:25,670
files and in the and all that cool stuff, but not for now.

22
00:01:26,060 --> 00:01:31,400
So let's go here with class, and let's come up with the name so bad request.

23
00:01:32,850 --> 00:01:39,630
And are really up to you, but I like to years the explicit name, so I know what is happening in this

24
00:01:39,630 --> 00:01:43,160
case, I'm extending from the custom API, everyone.

25
00:01:43,620 --> 00:01:47,010
OK, so and then pretty much the code is the same.

26
00:01:47,670 --> 00:01:51,660
So take this or use the super Oh, here's the message.

27
00:01:52,020 --> 00:01:54,780
And now I'm hard coding the status code one.

28
00:01:55,500 --> 00:01:57,180
And what's going to happen right now?

29
00:01:57,510 --> 00:02:02,700
Instead of using the custom API or one, we use the bat request one.

30
00:02:03,270 --> 00:02:10,199
And again, what's really, really, really cool is that we only need to set up this ones and then we

31
00:02:10,199 --> 00:02:12,470
can reuse it and all our project.

32
00:02:12,480 --> 00:02:17,970
So I know that this might seem tedious, but actually in the long run, it's much better.

33
00:02:18,180 --> 00:02:21,570
So what are we can do right now is just start out in the postman.

34
00:02:21,810 --> 00:02:26,520
So it's centered, and now we still have 400 and we have the message.

35
00:02:27,030 --> 00:02:34,170
And let's also set up one for not phone because it's going to be a little bit of time before we get

36
00:02:34,170 --> 00:02:38,580
to on authenticator and not one will do right away in a separate file.

37
00:02:39,330 --> 00:02:45,060
So what I want to do right now is again, copy and paste still within the controller and nonetheless

38
00:02:45,060 --> 00:02:48,120
change the name, let's say, or here not.

39
00:02:48,980 --> 00:02:53,870
Found error and instead of barrel quest, what is going to be the status code?

40
00:02:54,200 --> 00:02:56,090
It's going to be four or four.

41
00:02:56,570 --> 00:03:01,820
And when it comes to our constants we're looking for, we not found them again.

42
00:03:02,180 --> 00:03:03,650
We're not going to use it right now.

43
00:03:04,430 --> 00:03:10,190
But in general, I wanted to set it up right away so you can clearly see how it works.

44
00:03:10,490 --> 00:03:12,860
So we're still extending from this one.

45
00:03:13,310 --> 00:03:16,730
We still have the message all up, so we'll be able to pass it.

46
00:03:17,090 --> 00:03:20,960
But in this case, the status code is not found.

