1

00:00:01,110  -->  00:00:07,440
Not look at specific sections in the last lesson when we did them or at the very end we already looked

2

00:00:07,440  -->  00:00:09,690
at the supplement exceptions.

3

00:00:09,690  -->  00:00:14,950
Did the supplement exceptions work they can get off automatically by the try with resources Sendak's

4

00:00:14,960  -->  00:00:15,660
.

5

00:00:15,690  -->  00:00:20,680
So we were generating a one exception in the try block and the message was important exception.

6

00:00:20,910  -->  00:00:26,760
So this was the main exception that was being generated by this method called file copy with under exceptions

7

00:00:26,760  -->  00:00:32,910
that were being generated by these resources B and B do were embedded within what encapsulated within

8

00:00:32,910  -->  00:00:39,390
this exception I suppressed exceptions and we said that if we do not use private resources and data

9

00:00:39,390  -->  00:00:45,900
about if we use only try and finally Bross strike and finally block then only the exception the first

10

00:00:46,140  -->  00:00:51,630
exception that gets generated in the final block which would be one of these two would be to end by

11

00:00:51,630  -->  00:00:52,420
this method.

12

00:00:52,580  -->  00:00:58,120
I and the other two exceptions one is this one on one of them would be one of these.

13

00:00:58,230  -->  00:01:00,910
So both those exceptions will be ignored.

14

00:01:00,960  -->  00:01:04,240
So it be masked it's Carlos acception masking.

15

00:01:04,460  -->  00:01:07,830
And we said that we need to fix it manually.

16

00:01:07,830  -->  00:01:09,150
So that's what we are going to do here.

17

00:01:09,150  -->  00:01:12,150
So it's a continuation of their demo from the previous lesson.

18

00:01:12,180  -->  00:01:18,190
So there we had a file copy with him and we introduced two more matters on just one as file copy we

19

00:01:18,210  -->  00:01:19,000
thought.

20

00:01:19,290  -->  00:01:23,320
Which means that we are not using private resources syntax.

21

00:01:23,400  -->  00:01:25,510
So there is no automatic resource management.

22

00:01:25,680  -->  00:01:27,230
So it's just the same code.

23

00:01:27,600  -->  00:01:34,650
So since it is old fashioned try block so all the resources are declared outside and they're initialized

24

00:01:34,680  -->  00:01:41,070
inside the try block on everything else is seen we have generating that exception and then the finally

25

00:01:41,070  -->  00:01:43,180
block we are closing down resources.

26

00:01:43,260  -->  00:01:46,510
So we have this not clean looking court.

27

00:01:46,590  -->  00:01:47,740
So that's what we have.

28

00:01:47,780  -->  00:01:52,660
And in the main method we are again invoking this new method file copy we don't.

29

00:01:52,680  -->  00:01:54,990
So let me just read this.

30

00:01:55,170  -->  00:01:59,520
And as you can see only trivial exception to is being generated here.

31

00:01:59,550  -->  00:02:05,090
That's because that's the first exception that is getting generated here do.

32

00:02:05,160  -->  00:02:07,140
So that's the goes across.

33

00:02:07,290  -->  00:02:13,800
Throws the trivial exception to an exception and an important exception are simply are simply ignored

34

00:02:13,890  -->  00:02:14,070
.

35

00:02:14,170  -->  00:02:19,810
Ok so now to fix that we have this new method called Find copy we talked to.

36

00:02:19,830  -->  00:02:21,080
I just named or just do.

37

00:02:21,090  -->  00:02:25,700
Because you know it's kind of a solution that wasn't being offered as we should do.

38

00:02:25,950  -->  00:02:29,980
And we're hundred is handling exception masking biasa operation.

39

00:02:30,010  -->  00:02:38,050
So we are going to see how how the remaining two exceptions can be can be suppressed under and not suppressed

40

00:02:38,150  -->  00:02:43,230
in fact we want to just throw only this exception important exception like in the case of we three social

41

00:02:43,240  -->  00:02:48,720
Sendak's and the other two exceptions have to be suppressed exceptions within this exception.

42

00:02:48,720  -->  00:02:52,790
So for this it's just the same court but we're introducing this variable.

43

00:02:52,810  -->  00:02:57,560
Qualis Iowa exception it's a local variable and it is off by Aiwa exception.

44

00:02:57,850  -->  00:03:03,260
Now we have the tri block so in the earlier version there is only the trial and finally no catch block

45

00:03:03,270  -->  00:03:03,490
.

46

00:03:03,810  -->  00:03:07,110
But in this matter we also have the catch block.

47

00:03:07,290  -->  00:03:11,450
So when this gets executor distro motard gets ex-secret or die.

48

00:03:11,460  -->  00:03:17,790
The exception is generated with important exception so that gets caught here in this catch block and

49

00:03:17,790  -->  00:03:24,760
we're assigning this variable E to Iowa exception since Aiwa exception variable is also off by no exception

50

00:03:24,770  -->  00:03:25,610
.

51

00:03:25,740  -->  00:03:31,260
And then in the finally block here is how the resources acros we just check if Aiwa exception is not

52

00:03:31,260  -->  00:03:32,040
equal to.

53

00:03:32,460  -->  00:03:34,710
Let's say if I were exception was not generator.

54

00:03:34,770  -->  00:03:41,280
Then we go into the Alce block and we simply check if we do which is a first resource for does not equal

55

00:03:41,280  -->  00:03:43,790
to not for does not equal under it to be closed.

56

00:03:43,890  -->  00:03:46,740
But here on Aiwa exception was already generated.

57

00:03:46,770  -->  00:03:52,920
That is an important exception got generated and then we go inside and we once again do a check if B

58

00:03:52,920  -->  00:03:54,330
does not equal to none other.

59

00:03:54,400  -->  00:03:56,230
If it is not equal or not we close it.

60

00:03:56,460  -->  00:04:01,740
But if it also if the class met since the close method generates an exception we go into the catch block

61

00:04:01,740  -->  00:04:08,190
here and we added as in suppresive exception to the Aiwa exception which already got generated which

62

00:04:08,190  -->  00:04:14,040
is the important exception and could do that we have this new method and suppressed which is also part

63

00:04:14,040  -->  00:04:15,820
of the towable class.

64

00:04:15,870  -->  00:04:19,760
So it was also introduced in Java 7.

65

00:04:19,770  -->  00:04:25,130
But f here if Nuckols not look as if an important exception was not generated.

66

00:04:25,200  -->  00:04:30,060
So we will go into the else block and we are actually close indeed do.

67

00:04:30,210  -->  00:04:34,770
But if we do all since the two genders this exception then it could be caught here.

68

00:04:34,920  -->  00:04:38,990
And that exception will be directly assigned to Aiwa exception.

69

00:04:39,170  -->  00:04:43,180
That's because Aiwa exception is being generated for the first time.

70

00:04:43,200  -->  00:04:48,200
Now we need to also close the second mix of even though D2 throws an exception.

71

00:04:48,240  -->  00:04:50,660
We still have to close other resources.

72

00:04:50,760  -->  00:04:52,380
Otherwise Bill Haggarty Sosnik.

73

00:04:52,560  -->  00:04:57,360
So we go here we just again check Aiwa exception is not equal to null and this definitely could be not

74

00:04:57,360  -->  00:05:03,120
equal to null because not even the close method is throwing an exception.

75

00:05:03,180  -->  00:05:06,950
Of course another important exception is also being generated.

76

00:05:06,960  -->  00:05:12,210
So anyway it's just the same court only thing is being replaced by a deal with repellers might be here

77

00:05:12,220  -->  00:05:12,320
.

78

00:05:12,420  -->  00:05:18,760
So if there is an exception we go here and we check if B if we invoke disclose method here.

79

00:05:18,760  -->  00:05:20,520
And also gender's an exception.

80

00:05:20,520  -->  00:05:26,740
Once again we had we captured and we added to the main exception to the IWA exception.

81

00:05:26,910  -->  00:05:30,950
Otherwise we go into the old sloop and we just do this.

82

00:05:31,170  -->  00:05:38,020
We check if I mean Wilco's method and if it throws an exception we assign it to the Aiwa exception.

83

00:05:38,020  -->  00:05:41,590
Q So that's the first time that Aiwa exception is getting generated.

84

00:05:41,730  -->  00:05:47,520
Now the same thing is done for in resource and for the open source sensus the last resort.

85

00:05:47,760  -->  00:05:49,510
Once again we have the if else block.

86

00:05:49,620  -->  00:05:52,720
If I were the exception is not equal to invoke Glos method.

87

00:05:52,860  -->  00:05:58,380
And B if it throws an exception we catch it and we added to the Aiwa exception and then we threw the

88

00:05:58,380  -->  00:05:59,880
Iowa exception.

89

00:06:00,300  -->  00:06:03,730
So that's the exception that's getting thrown by this method.

90

00:06:04,260  -->  00:06:05,860
Now if that's not the case.

91

00:06:05,880  -->  00:06:13,260
So if I were exception our variable is not assigned a value so far which means no exception has been

92

00:06:13,260  -->  00:06:14,510
generated so far.

93

00:06:14,520  -->  00:06:18,500
Then we go into the envelope and we close up our true source.

94

00:06:18,510  -->  00:06:23,510
And if this is an exception then that would be the only exception that gets generated.

95

00:06:23,700  -->  00:06:24,580
So that is it.

96

00:06:24,720  -->  00:06:26,750
So let me just go ahead and run this.

97

00:06:26,860  -->  00:06:27,810
Make it two here

98

00:06:30,750  -->  00:06:32,120
and here you go.

99

00:06:32,130  -->  00:06:39,780
So now that is no more exception masking what we have is so pleasant exception on that as it looks exactly

100

00:06:39,780  -->  00:06:45,450
identical to the way we had four when we when we were using the tried with resource index.

101

00:06:45,450  -->  00:06:50,400
So you have that true somewhat as exceptions which are the trivial exceptions and the main exception

102

00:06:50,400  -->  00:06:52,730
is the important exception.

103

00:06:52,720  -->  00:07:00,150
OK so as you can see we have to write all of discord to get office of exceptions and private resources

104

00:07:00,150  -->  00:07:02,990
and Datsuns automatically handling all of this.

105

00:07:03,000  -->  00:07:05,160
So that's the nice thing about that.

106

00:07:05,220  -->  00:07:11,820
But Drive-Thru sources of Sendak's specific do only resources if you're not using recloser resources

107

00:07:11,820  -->  00:07:15,290
then you have to go get try finally block.

108

00:07:15,810  -->  00:07:16,910
So that's about it.

109

00:07:17,190  -->  00:07:18,140
Thank you.

110

00:07:18,140  -->  00:07:22,650
And happy coding on this new class will also be uploader to the resources section resources section
