1
00:00:00,120 --> 00:00:00,450
All right.

2
00:00:00,480 --> 00:00:03,870
And one more arrow that I want to handle is the unique error.

3
00:00:04,320 --> 00:00:09,510
So I already register John with John at Gmail dot com.

4
00:00:09,870 --> 00:00:17,520
So even if I'll change year around the name and I'll say Peter, but if I'll still use the same name,

5
00:00:17,820 --> 00:00:19,410
I should get back the error.

6
00:00:19,830 --> 00:00:23,100
Now, the moment the error is going to be generic, correct?

7
00:00:23,460 --> 00:00:24,840
Well, how something went wrong?

8
00:00:25,020 --> 00:00:25,860
Try again later.

9
00:00:26,120 --> 00:00:31,110
And again, the response is 500, because we're not checking more up in the error handler.

10
00:00:31,410 --> 00:00:33,440
So let's navigate back on.

11
00:00:33,670 --> 00:00:39,570
I'm fully aware that some people might find this annoying, but in my case, I will uncomment my entire

12
00:00:39,570 --> 00:00:43,380
error response and I'll comment out of the default error.

13
00:00:43,710 --> 00:00:47,820
And don't worry, we won't be doing that in every video Charlotte mission back.

14
00:00:48,150 --> 00:00:55,620
And what you'll notice is the error object or in this case, there is a cold property.

15
00:00:56,250 --> 00:00:57,990
So this is what we're getting back.

16
00:00:58,470 --> 00:01:04,050
We're getting back a error object with a cold property, and the value is this one.

17
00:01:04,290 --> 00:01:06,990
So we have one one and then three zeroes.

18
00:01:07,440 --> 00:01:09,270
So when it comes to our condition.

19
00:01:10,280 --> 00:01:16,280
We'll actually check for the cold property and whether the value is equal to this.

20
00:01:17,150 --> 00:01:24,470
Now that's going to be the condition inside of the condition instead of object values will use object

21
00:01:24,470 --> 00:01:28,910
keys and we'll pass in the error and then key value.

22
00:01:29,300 --> 00:01:31,490
So this is going to be an object.

23
00:01:32,180 --> 00:01:33,190
I'm in there.

24
00:01:33,200 --> 00:01:40,160
I just want to access the properties that the object has because I want to send back such and such property

25
00:01:40,400 --> 00:01:44,720
has to be unique and you'll see what I'm talking about in a second.

26
00:01:45,140 --> 00:01:54,200
And just like with object values, if you need a refresher on object keys, the Amdocs is a very good

27
00:01:54,200 --> 00:01:55,070
place to start.

28
00:01:55,280 --> 00:01:56,800
So let's navigate back.

29
00:01:56,810 --> 00:02:02,260
And like I said, the first thing we want to do is to set up the condition where again, there is a

30
00:02:02,270 --> 00:02:04,880
our object now inside of that object.

31
00:02:05,120 --> 00:02:11,930
There might be a cold property and if it exists, but I want to check whether the value for that property

32
00:02:12,140 --> 00:02:14,450
is 11 and nine three zero.

33
00:02:14,480 --> 00:02:16,400
So let's go here with our code.

34
00:02:16,790 --> 00:02:21,890
And if that is equal to one one one nine three zero there, this is the case.

35
00:02:22,250 --> 00:02:28,190
Well, first again, let's set up the proper status code, which is going to be for honor like so.

36
00:02:28,580 --> 00:02:31,130
So in this case, we can just copy and paste.

37
00:02:31,460 --> 00:02:34,490
And then the second thing, let's set up the message.

38
00:02:34,700 --> 00:02:38,410
So say here, default error and message is equal to.

39
00:02:38,750 --> 00:02:42,020
Now first, I want to set up the template string that's number one.

40
00:02:42,260 --> 00:02:46,100
And then I'll say field has to be unique.

41
00:02:46,250 --> 00:02:47,660
Now which field am I talking on?

42
00:02:47,930 --> 00:02:52,390
Well, like I said, we'll use object keys and not to do that.

43
00:02:52,410 --> 00:03:00,260
We'll have to set up our interpolation here and we'll use object van keys and then let's pass in the

44
00:03:00,260 --> 00:03:00,650
error.

45
00:03:00,950 --> 00:03:04,040
That's the entire object that we have.

46
00:03:04,430 --> 00:03:08,180
And more specifically, I'm looking for this key value.

47
00:03:08,540 --> 00:03:15,200
So let's go here and let's say key and value, that's the object that I want to pass in.

48
00:03:15,560 --> 00:03:20,780
And once I save it, you'll notice if we go back to the post mount and if we send.

49
00:03:21,050 --> 00:03:26,930
And of course, nothing changed because I should comment on the first one and then I'll come on the

50
00:03:26,930 --> 00:03:33,750
second one where we have the default error message and now you'll notice the email field has to be unique.

51
00:03:33,870 --> 00:03:35,930
Now there is a space missing.

52
00:03:36,680 --> 00:03:39,950
So once we add this one, everything should be correct.

53
00:03:40,190 --> 00:03:47,120
So if the user is going to try to register with an email that is already in use, then we'll send back

54
00:03:47,120 --> 00:03:51,620
the 4hana response with the message email field has to be unique.

