1
00:00:00,610 --> 00:00:06,610
In this video, we are going to display an error or errors in case we have one.

2
00:00:06,610 --> 00:00:08,080
For example, one.

3
00:00:08,080 --> 00:00:10,960
I create a post without providing the details.

4
00:00:10,960 --> 00:00:18,790
We have this JSON data by saying that all files are required, so we are having this error inside the

5
00:00:18,790 --> 00:00:20,560
post creation controller.

6
00:00:20,560 --> 00:00:28,720
So let me close this once and let me close the open folders and let's go to Controllers Post and here

7
00:00:28,720 --> 00:00:29,350
we go.

8
00:00:29,350 --> 00:00:32,740
So let's locate where we have possible errors.

9
00:00:32,920 --> 00:00:36,400
Let me remove this one from here that the console log.

10
00:00:36,400 --> 00:00:40,180
And in here we are going to send the error to the user.

11
00:00:40,180 --> 00:00:46,780
So down here I'll make use of return red dot render.

12
00:00:48,630 --> 00:00:54,510
Post and then the post creation or art post templates.

13
00:00:57,140 --> 00:01:01,510
We're going to be as at post Perfect.

14
00:01:02,570 --> 00:01:12,470
An hour passed in the error as error and then the value is equal to all fails required.

15
00:01:13,550 --> 00:01:15,740
And let me remove this one.

16
00:01:17,410 --> 00:01:21,610
Next place is inside the catch block here.

17
00:01:21,640 --> 00:01:30,490
So I'm going to copy this one and inside the catch, paste it here and remove this one.

18
00:01:30,490 --> 00:01:37,120
And for the actual message, we are going to use the one that will come from the server.

19
00:01:39,070 --> 00:01:40,810
Right for success.

20
00:01:40,810 --> 00:01:46,950
We are going to redirect the user to the homepage or the profile page.

21
00:01:46,960 --> 00:01:54,130
The choice is yours going to be as rest, redirect and go to homepage.

22
00:01:54,160 --> 00:01:55,230
That is it.

23
00:01:55,240 --> 00:01:58,270
So let's go back, refresh.

24
00:01:58,600 --> 00:02:02,350
Let me hit create and I'm still on the form.

25
00:02:02,350 --> 00:02:04,960
So let's go ahead and then display the error.

26
00:02:05,230 --> 00:02:12,520
So I'm going to copy the error syntax for the log in, which is this one.

27
00:02:12,970 --> 00:02:15,610
And let me go to the outpost.

28
00:02:17,290 --> 00:02:22,450
And for the error, which is this one I'm going to replace with this one.

29
00:02:22,960 --> 00:02:25,840
All right, so let's refresh it.

30
00:02:25,990 --> 00:02:30,580
Let me go to profile, new and create.

31
00:02:31,060 --> 00:02:36,130
You can see I have all fields required, meaning that it worked.

32
00:02:36,160 --> 00:02:42,970
In the next video, let's go ahead and create a function to truncate the description of a post.

