So we have these two nice functions, client error and server error, but we're not using them anywhere,
so let's go put them in a few places where they might be useful.
And the most obvious place to check first is handlers.
So I'm in my handlers thought, go file and let's start looking for where we throw errors.
Well, first of all, we don't need this session bit on the home page anymore, so let's get rid of
that and let's make sure that we're not actually using that anywhere in the home page template that's
under templates home.
Am I using it anywhere?
And look like it, just let me search for session.
No, I'm not good, so that's good.
So that's gone.
Nothing there.
This does potentially throw an error, but I'm not too worried about that one because I just rendering
the template.
So I'll skip that one for now.
Here in the about page.
Again, I'm creating all this string map stuff, which we did when we were learning about session.
So let's just get rid of that.
We're not using it at all and make sure we're not using it anywhere on the actual template.
Should have done this clean up earlier, but I didn't.
So let's get rid of this
and go look at the about page.
Make sure we're not using it anywhere.
No, I'm not.
That's good.
Let's keep going.
Reservation.
So anywhere in this that I'm using a reservation.
I'm putting a reservation into that.
No, let's try a post reservation.
Aha.
Here.
I'm trying to pass the form and if there's an error I actually want to handle that.
So now rather than just logging it and returning it, let's actually use our error handling package.
So this would be a server error.
Let's try that.
So helper's dot server error, which requires two parameters, our response rate or which we have and
the error.
And that's all we have to do.
So when we call, when something goes wrong, parsing the form now, it will write right now to the
standard out the terminal.
It'll give us detailed error messages.
So let's see if we can actually invoke this.
And I'm going to do that by creating an error.
So I actually don't want to bother trying to duplicate parsing in a form error.
I'll just redefine my error to say error equals errors, error dot new, errors dot new and I'll create
the error message.
This is an error message.
So this is on posting the reservation.
So what I've done here and it's just give me a warning saying this condition is always true.
I know that.
I'm just trying to invoke this error message.
Let's open our terminal window, clear the screen and run our application.
So I'm using my Rundell S.H. script.
If you're on Windows who use you run that script, let's run it.
So it's now running.
Let's go to our browser window and let's hit our application.
And what I want to do is create a reservation.
So I'll go to the URL that allows us to display that screen, make reservation and fill out this form
A, B, C at here dot com and some phone number.
And they should fire our server error and it does internal server error.
And if we look at the log, which is currently written to standard out, we actually have all of this
information, all of which is very useful.
So it just generates this error message that I created right here.
This is an error message and that tells me where it took place, it took place.
And I can go all the way down to Dargo helper's dot go twenty three.
And if I click on that in this idy it takes me right to that line and shows me where it took place.
So I have this information so we're on error.
Stocco which actually took place in handlers go.
So it takes me right to the line that generated that error and that is incredibly useful information.
So that's great.
So let's stop our application.
Cleared the screen.
Hi.
This window and get rid of this manual error we introduced that.
It shows that it actually works.
Let's keep going and see if there's anywhere else we need to use this so we have that.
No errors here, no errors here.
There's one.
So when you try to marshal the Jason, we're just logging the error right now.
Well, let's not do that.
Let's actually go helper's server error w and the error.
And then of course we want to return after that.
We don't want to go any further, so I'll put a return in there as well.
Anywhere else.
Cannot get info from session apte error log emcdda app error log and print line and we'll just print
the error message and the airlock will be
can't get error from session.
So we're just writing that error and everything else is the same for that one.
And I think that's it for this case.
So and we now have a method of writing useful information to the client window to the browser window.
When something goes wrong, we have a server error and we also have a means of writing to the browser
window when there is a client error, which we're not using yet, but we will use before this course
is over.