1
00:00:00,990 --> 00:00:05,670
Inside of our case, we now need to take a look at that incoming air, figure out exactly what went

2
00:00:05,670 --> 00:00:08,240
wrong, and then print out some appropriate air message to the user.

3
00:00:08,790 --> 00:00:12,540
So I'm going to show you a very quick example of how you might do this, but I'll leave it up to you

4
00:00:12,540 --> 00:00:17,370
if you want to go through here and kind of put together some more exhaustive cases around handling this

5
00:00:17,370 --> 00:00:17,610
error.

6
00:00:18,000 --> 00:00:22,800
In other words, right now, we know for a hundred percent that one possible error is a port already

7
00:00:22,800 --> 00:00:23,460
being in use.

8
00:00:23,670 --> 00:00:25,530
So we'll add in some code to handle that case.

9
00:00:25,710 --> 00:00:29,400
But there might be other kinds of errors that we just don't really know exist just yet.

10
00:00:29,550 --> 00:00:33,360
And so I'm going to allow you to kind of figure out what those other kinds of errors might be.

11
00:00:34,350 --> 00:00:39,900
So we'll put in just a very simple approach here, we'll say if your code is.

12
00:00:41,190 --> 00:00:47,850
E atter in use, then let's go ahead and print up some appropriate air message to our user, then maybe

13
00:00:47,850 --> 00:00:52,470
we'll do a console air of something like or is in use.

14
00:00:52,860 --> 00:00:55,620
Try running on a different port.

15
00:01:01,150 --> 00:01:03,100
And then going to delete the other console log.

16
00:01:04,940 --> 00:01:06,890
And actually, let's bring that back.

17
00:01:07,910 --> 00:01:13,370
And we'll just put in an else case, so like I said, we're only going to handle the one Distin situation

18
00:01:13,430 --> 00:01:13,910
right now.

19
00:01:17,590 --> 00:01:21,220
So if a port is in use, that's great, we'll tell you exactly what's going on.

20
00:01:21,400 --> 00:01:24,510
Otherwise, if it's any other kind of area, we're going to tell them, hey, something went wrong.

21
00:01:24,520 --> 00:01:26,580
We don't really know what figure out what's going on yourself.

22
00:01:26,860 --> 00:01:27,310
Not great.

23
00:01:27,310 --> 00:01:29,220
But again, I'm going to leave it up to you to kind of fix that up.

24
00:01:29,950 --> 00:01:33,700
Now, the last thing we might want to do here, and this is kind of optional, kind of comes down to

25
00:01:34,090 --> 00:01:37,270
some other topics are going to discuss a little bit later on around Seelie design.

26
00:01:37,510 --> 00:01:42,550
But what we might also want to do inside of here is force an exit of our program is essentially we just

27
00:01:42,700 --> 00:01:47,040
failed to start up our server and that was the entire point of running the server command.

28
00:01:47,530 --> 00:01:51,850
So if we fail to start up our server, then we probably want to say, you know what, there's no point

29
00:01:51,850 --> 00:01:55,470
in running our program anymore and we just want to forcibly exit.

30
00:01:55,870 --> 00:01:59,170
So we might do a process, not exit one.

31
00:02:00,030 --> 00:02:05,880
So this is going to forcibly exit our program with a status code of one, which pretty much just indicates

32
00:02:05,880 --> 00:02:09,449
that we are exiting with an unsuccessful run of our program.

33
00:02:10,430 --> 00:02:13,390
Let's say this again, back over a quick test.

34
00:02:13,690 --> 00:02:17,880
I'll do another note, indexer, and now we're told there is a news.

35
00:02:17,890 --> 00:02:18,980
Try running on a different port.

36
00:02:19,030 --> 00:02:19,660
Very good.

37
00:02:19,660 --> 00:02:22,030
And we get kicked back directly to our terminal.

38
00:02:23,920 --> 00:02:28,450
The last thing we might do here to kind of enhance the user experience would be maybe tell the user

39
00:02:28,450 --> 00:02:31,450
how to run on a different port because we're sure not telling them that right now.

40
00:02:31,780 --> 00:02:36,060
So we might tell them to try to use the P command to run on a different port manually.

41
00:02:36,460 --> 00:02:39,400
So it might say try to run on a different port.

42
00:02:39,400 --> 00:02:43,870
And when you do add in, dash up on some other port, maybe in this case four thousand six.

43
00:02:43,870 --> 00:02:46,240
And if we do that, then everything is going to run successfully.

44
00:02:48,870 --> 00:02:50,660
OK, so this looks pretty good.

45
00:02:50,700 --> 00:02:52,980
We've now got some reasonable error handling inside of here.

46
00:02:53,460 --> 00:02:58,510
The very last thing I would like to do is if we do start up our search process successfully and we know

47
00:02:58,530 --> 00:03:03,000
if we start listening for actual traffic, we should probably tell the user that, well, everything

48
00:03:03,000 --> 00:03:05,750
is running successfully and how to now interact with our application.

49
00:03:05,910 --> 00:03:10,380
You might notice that right now, if we put in that custom port and we start the server, there's no

50
00:03:10,380 --> 00:03:12,020
message printed to the user whatsoever.

51
00:03:12,030 --> 00:03:14,490
And so they might be really confused about what they're supposed to do right now.

52
00:03:15,210 --> 00:03:19,480
So to handle that right after calling serve right here, we might decide to just put in a very quick

53
00:03:19,480 --> 00:03:20,160
console log.

54
00:03:21,090 --> 00:03:27,960
With a template string, notice the tactics and we could put in something like opened file name, that's

55
00:03:27,960 --> 00:03:35,940
the name of the file that we just opened and we are reading cells from and maybe navigate to http localhost

56
00:03:36,450 --> 00:03:36,990
ohlin.

57
00:03:38,000 --> 00:03:38,840
And then port.

58
00:03:39,890 --> 00:03:41,900
To edit the file.

59
00:03:43,060 --> 00:03:47,830
So essentially just some directions that they need to open up their browser, go to that address if

60
00:03:47,830 --> 00:03:52,180
they want to see that interface and start interacting with that list of cells, one little fix I need

61
00:03:52,180 --> 00:03:55,900
to put inside of your is it needs to be option Stockport, not just port.

62
00:04:00,350 --> 00:04:05,330
Now, if we save this and run it one last time, now we're giving the user some very clear instructions

63
00:04:06,170 --> 00:04:11,660
so they could very easily copy that, take it over to the browser, see our react application appear

64
00:04:12,020 --> 00:04:14,300
and start working round with that list of cells.

65
00:04:15,540 --> 00:04:19,410
OK, so this looks pretty good, I think that we are pretty much all done with our Seelie, we've got

66
00:04:19,410 --> 00:04:21,000
some pretty reasonable logic inside of here.

67
00:04:21,540 --> 00:04:25,560
So we're going to take a pause right here, as usual, and back to the next video and continue work

68
00:04:25,560 --> 00:04:27,090
on our local API.

