All right.
And one more arrow that I want to handle is the unique error.
So I already register John with John at Gmail dot com.
So even if I'll change year around the name and I'll say Peter, but if I'll still use the same name,
I should get back the error.
Now, the moment the error is going to be generic, correct?
Well, how something went wrong?
Try again later.
And again, the response is 500, because we're not checking more up in the error handler.
So let's navigate back on.
I'm fully aware that some people might find this annoying, but in my case, I will uncomment my entire
error response and I'll comment out of the default error.
And don't worry, we won't be doing that in every video Charlotte mission back.
And what you'll notice is the error object or in this case, there is a cold property.
So this is what we're getting back.
We're getting back a error object with a cold property, and the value is this one.
So we have one one and then three zeroes.
So when it comes to our condition.
We'll actually check for the cold property and whether the value is equal to this.
Now that's going to be the condition inside of the condition instead of object values will use object
keys and we'll pass in the error and then key value.
So this is going to be an object.
I'm in there.
I just want to access the properties that the object has because I want to send back such and such property
has to be unique and you'll see what I'm talking about in a second.
And just like with object values, if you need a refresher on object keys, the Amdocs is a very good
place to start.
So let's navigate back.
And like I said, the first thing we want to do is to set up the condition where again, there is a
our object now inside of that object.
There might be a cold property and if it exists, but I want to check whether the value for that property
is 11 and nine three zero.
So let's go here with our code.
And if that is equal to one one one nine three zero there, this is the case.
Well, first again, let's set up the proper status code, which is going to be for honor like so.
So in this case, we can just copy and paste.
And then the second thing, let's set up the message.
So say here, default error and message is equal to.
Now first, I want to set up the template string that's number one.
And then I'll say field has to be unique.
Now which field am I talking on?
Well, like I said, we'll use object keys and not to do that.
We'll have to set up our interpolation here and we'll use object van keys and then let's pass in the
error.
That's the entire object that we have.
And more specifically, I'm looking for this key value.
So let's go here and let's say key and value, that's the object that I want to pass in.
And once I save it, you'll notice if we go back to the post mount and if we send.
And of course, nothing changed because I should comment on the first one and then I'll come on the
second one where we have the default error message and now you'll notice the email field has to be unique.
Now there is a space missing.
So once we add this one, everything should be correct.
So if the user is going to try to register with an email that is already in use, then we'll send back
the 4hana response with the message email field has to be unique.