1
00:00:01,750 --> 00:00:06,720
So we have these two nice functions, client error and server error, but we're not using them anywhere,

2
00:00:06,730 --> 00:00:09,910
so let's go put them in a few places where they might be useful.

3
00:00:09,910 --> 00:00:12,940
And the most obvious place to check first is handlers.

4
00:00:13,700 --> 00:00:18,190
So I'm in my handlers thought, go file and let's start looking for where we throw errors.

5
00:00:18,220 --> 00:00:22,900
Well, first of all, we don't need this session bit on the home page anymore, so let's get rid of

6
00:00:22,900 --> 00:00:29,260
that and let's make sure that we're not actually using that anywhere in the home page template that's

7
00:00:29,260 --> 00:00:31,270
under templates home.

8
00:00:31,960 --> 00:00:33,030
Am I using it anywhere?

9
00:00:36,250 --> 00:00:38,230
And look like it, just let me search for session.

10
00:00:39,230 --> 00:00:40,900
No, I'm not good, so that's good.

11
00:00:40,900 --> 00:00:41,550
So that's gone.

12
00:00:42,790 --> 00:00:43,770
Nothing there.

13
00:00:43,930 --> 00:00:48,490
This does potentially throw an error, but I'm not too worried about that one because I just rendering

14
00:00:48,490 --> 00:00:49,030
the template.

15
00:00:49,040 --> 00:00:50,290
So I'll skip that one for now.

16
00:00:50,740 --> 00:00:52,150
Here in the about page.

17
00:00:52,150 --> 00:00:56,140
Again, I'm creating all this string map stuff, which we did when we were learning about session.

18
00:00:56,150 --> 00:00:57,190
So let's just get rid of that.

19
00:00:58,300 --> 00:01:04,540
We're not using it at all and make sure we're not using it anywhere on the actual template.

20
00:01:05,350 --> 00:01:07,220
Should have done this clean up earlier, but I didn't.

21
00:01:07,240 --> 00:01:08,560
So let's get rid of this

22
00:01:11,680 --> 00:01:13,770
and go look at the about page.

23
00:01:13,960 --> 00:01:15,460
Make sure we're not using it anywhere.

24
00:01:15,760 --> 00:01:16,590
No, I'm not.

25
00:01:16,680 --> 00:01:17,230
That's good.

26
00:01:18,100 --> 00:01:18,840
Let's keep going.

27
00:01:19,690 --> 00:01:20,550
Reservation.

28
00:01:20,740 --> 00:01:23,380
So anywhere in this that I'm using a reservation.

29
00:01:23,380 --> 00:01:24,820
I'm putting a reservation into that.

30
00:01:24,830 --> 00:01:27,040
No, let's try a post reservation.

31
00:01:27,040 --> 00:01:27,490
Aha.

32
00:01:27,640 --> 00:01:28,120
Here.

33
00:01:28,330 --> 00:01:32,720
I'm trying to pass the form and if there's an error I actually want to handle that.

34
00:01:32,740 --> 00:01:38,250
So now rather than just logging it and returning it, let's actually use our error handling package.

35
00:01:38,260 --> 00:01:41,210
So this would be a server error.

36
00:01:41,230 --> 00:01:41,880
Let's try that.

37
00:01:42,400 --> 00:01:49,090
So helper's dot server error, which requires two parameters, our response rate or which we have and

38
00:01:49,090 --> 00:01:49,510
the error.

39
00:01:52,060 --> 00:01:53,210
And that's all we have to do.

40
00:01:53,380 --> 00:01:59,500
So when we call, when something goes wrong, parsing the form now, it will write right now to the

41
00:01:59,500 --> 00:02:00,790
standard out the terminal.

42
00:02:01,180 --> 00:02:03,190
It'll give us detailed error messages.

43
00:02:03,200 --> 00:02:05,410
So let's see if we can actually invoke this.

44
00:02:05,860 --> 00:02:08,260
And I'm going to do that by creating an error.

45
00:02:08,530 --> 00:02:13,300
So I actually don't want to bother trying to duplicate parsing in a form error.

46
00:02:13,330 --> 00:02:25,240
I'll just redefine my error to say error equals errors, error dot new, errors dot new and I'll create

47
00:02:25,240 --> 00:02:26,110
the error message.

48
00:02:26,140 --> 00:02:28,780
This is an error message.

49
00:02:29,950 --> 00:02:31,710
So this is on posting the reservation.

50
00:02:32,290 --> 00:02:35,830
So what I've done here and it's just give me a warning saying this condition is always true.

51
00:02:35,830 --> 00:02:36,490
I know that.

52
00:02:36,490 --> 00:02:38,340
I'm just trying to invoke this error message.

53
00:02:38,800 --> 00:02:43,540
Let's open our terminal window, clear the screen and run our application.

54
00:02:44,890 --> 00:02:47,800
So I'm using my Rundell S.H. script.

55
00:02:47,800 --> 00:02:50,710
If you're on Windows who use you run that script, let's run it.

56
00:02:53,260 --> 00:02:54,100
So it's now running.

57
00:02:54,490 --> 00:02:59,470
Let's go to our browser window and let's hit our application.

58
00:03:04,420 --> 00:03:06,520
And what I want to do is create a reservation.

59
00:03:06,520 --> 00:03:15,010
So I'll go to the URL that allows us to display that screen, make reservation and fill out this form

60
00:03:15,010 --> 00:03:19,000
A, B, C at here dot com and some phone number.

61
00:03:19,270 --> 00:03:24,880
And they should fire our server error and it does internal server error.

62
00:03:24,880 --> 00:03:30,490
And if we look at the log, which is currently written to standard out, we actually have all of this

63
00:03:30,490 --> 00:03:32,350
information, all of which is very useful.

64
00:03:32,830 --> 00:03:36,310
So it just generates this error message that I created right here.

65
00:03:36,310 --> 00:03:40,510
This is an error message and that tells me where it took place, it took place.

66
00:03:40,510 --> 00:03:44,110
And I can go all the way down to Dargo helper's dot go twenty three.

67
00:03:44,320 --> 00:03:49,600
And if I click on that in this idy it takes me right to that line and shows me where it took place.

68
00:03:50,470 --> 00:03:53,080
So I have this information so we're on error.

69
00:03:53,080 --> 00:03:55,840
Stocco which actually took place in handlers go.

70
00:03:55,840 --> 00:04:00,910
So it takes me right to the line that generated that error and that is incredibly useful information.

71
00:04:01,000 --> 00:04:01,740
So that's great.

72
00:04:01,750 --> 00:04:03,460
So let's stop our application.

73
00:04:04,270 --> 00:04:05,140
Cleared the screen.

74
00:04:05,620 --> 00:04:05,890
Hi.

75
00:04:05,890 --> 00:04:09,800
This window and get rid of this manual error we introduced that.

76
00:04:09,820 --> 00:04:11,050
It shows that it actually works.

77
00:04:11,080 --> 00:04:15,460
Let's keep going and see if there's anywhere else we need to use this so we have that.

78
00:04:15,730 --> 00:04:18,340
No errors here, no errors here.

79
00:04:19,330 --> 00:04:20,110
There's one.

80
00:04:20,410 --> 00:04:23,920
So when you try to marshal the Jason, we're just logging the error right now.

81
00:04:23,920 --> 00:04:24,760
Well, let's not do that.

82
00:04:25,090 --> 00:04:31,570
Let's actually go helper's server error w and the error.

83
00:04:33,130 --> 00:04:35,050
And then of course we want to return after that.

84
00:04:35,050 --> 00:04:38,050
We don't want to go any further, so I'll put a return in there as well.

85
00:04:38,890 --> 00:04:40,100
Anywhere else.

86
00:04:40,120 --> 00:04:51,400
Cannot get info from session apte error log emcdda app error log and print line and we'll just print

87
00:04:51,400 --> 00:04:53,770
the error message and the airlock will be

88
00:04:57,070 --> 00:05:00,790
can't get error from session.

89
00:05:03,310 --> 00:05:06,310
So we're just writing that error and everything else is the same for that one.

90
00:05:06,310 --> 00:05:07,660
And I think that's it for this case.

91
00:05:07,840 --> 00:05:14,140
So and we now have a method of writing useful information to the client window to the browser window.

92
00:05:14,140 --> 00:05:19,780
When something goes wrong, we have a server error and we also have a means of writing to the browser

93
00:05:19,780 --> 00:05:23,930
window when there is a client error, which we're not using yet, but we will use before this course

94
00:05:23,950 --> 00:05:24,370
is over.
