That's no go ahead and look at the third item which is item 63 and it is about how we can associate 2
additional information with an exception so that it can help in better debugging. 3
And it's a very effective tool for debugging purpose. 4
And the last item we will see in the next list. 5
So let's just go ahead and extend our code and look at the third item OK let's go ahead and continue 6
with all of them all. 7
So earlier we had this API for marching exception. 8
And here is the exact output and you can see that there is this the Stockbridge's that is getting printed 9
here. 10
But sometimes this doctress alone may not be helpful to the debugger. 11
So the debugger might need some additional information in order to fix the problem. 12
Many times it might be good enough but not but sometimes the debugger might need some additional information 13
. 14
And sometimes the debugger is debugging might want to reproduce the problem and it might be very difficult 15
to reproduce the error. 16
So it is better to have more additional information along with the exception. 17
Sometimes that will be very useful. 18
An item sixty three is all about that. 19
So item 63 says that if we go here into API parser it basically say it basically just to include as 20
much information as possible from the context. 21
When an exception has been generated for example it suggests that we can use all the parameter Dometic 22
parameters information and also any any relevant instance valuable information. 23
So the items are just to pick all of this information and to encapsulate that in the exception itself 24
. 25
So that can be done. 26
Information can be encapsulated because of it into a bill. 27
There is a constructor which takes a string as an input. 28
So the items says we can concatenate all of this information and the parameter information on any instance 29
variable information and we can pass it on unbe can invoke that particular construct. 30
Here we are invoking a constructor but we can also invoke the other constructor and for that we need 31
to include it here we need to create that constructor. 32
So let's just go ahead and see Jenrette constructors from superclass. 33
So let's just set de-select on and set up this one exception of string. 34
So this is the thing. 35
And so we have a new constructor within our odd exception class to simply invoking the constructor from 36
the superclass which is an exception. 37
So just go ahead and also pass a string here. 38
All we need to do is this message here. 39
So it's a detail message that we are passing. 40
Just Mode-S So we're passing the response which is from here. 41
Doctoral response that we got from the lip service and we are also passing the element which is giving 42
us the problem which is the court and the part not information the name of the partner. 43
So all of this will be no part of the exception itself. 44
OK. 45
And it's a very effective way of dealing with exceptions in certain in certain pieces of court especially 46
when you are hoping some data integration systems on you if you run into such issues so you can put 47
inter-regional information on pass it over to the partner beams. 48
Double up. 49
So OK so that would be very helpful for them to fix the problem. 50
And personally also I have encountered such issues and these this kind of additional information has 51
has really helped me out to fix the problem so I was able to pass a pass on this information to the 52
excellent other team and they were able to fix it. 53
So it's really very helpful. 54
So let's just go back here. 55
And there's sprint that one more time 56
so as you can see now the exception that has the stackless as before it opens the exception name and 57
it's also providing the additional information. 58
So this is called as a daily message. 59
So that's the prince doctress matter. 60
Let's also look at 61
the string matters. 62
So this is a prince doctress method from the exception class. 63
Now let's look at the string third string method basically it prints only the first line and it's not 64
going to print the stack trace. 65
So as you can see here you are to string notes printing on the fosterling. 66
Now there is also a method called Get message which only opens only the original information yes knew 67
that 68
you can see here it only provides additional information. 69
So that's how you can pass additional information but the items is that one problem with this is sometimes 70
don't the person might want to extract this additional information not the entire string but just the 71
additional information embedded within the string unfolded. 72
They might write some parsing code extractor But the problem with that is here. 73
So we're constructing the string so API Parslow is a different component. 74
Right. 75
It's not. 76
So exceptions demo is actually incorporating API parser now in the next release. 77
If this you know if there are changes Disfarmer so I can start off response. 78
If he changes it to something else and if he or if an exception is demo we are using this particular 79
string to parse the response then because the format has been changed in the next release due to that 80
you know the code or here might break the parsing code might break. 81
So the items say is that you have certain parameters since exception class is simply an exception. 82
It's simply a class. 83
So why not have some parameters. 84
Why not House officials here that represent the artist the individual feels individual values within 85
the additional information. 86
The response the element and the partner so we can maintain individual individual feels here and we 87
can expose them through some access sort of metrics and to initialize them we can have a new constructor 88
. 89
So when we are invoking the ax instead of invoking this particular constructor we will invoke a new 90
constructor which will actually initialize all those fields which represent this these individual elements 91
within the traditional information. 92
So that's the suggestion that that item gives and it is not followed. 93
It seems according to Josh Block it's not even followed well within the Java library itself. 94
But he highlighted the comments following this particular idiom. 95
So let's just go ahead and do that. 96
So let's first introduce those variables 97
it's automatically created construct or BART we are. 98
It's a new constructor. 99
So we are going to join de-construct de-construct from the fetus. 100
Just say all of the pentameters on this. 101
So I think it's also a way to access some of my thoughts here. 102
So generous good persons are cursed under this system set up get us 103
so we have all the accessories here and the fields are initialized here. 104
And we can also in the superclasses string constructor in this way. 105
So you're also doing that and in addition to that we are doing this. 106
OK. 107
So that's the nice thing unbecome now for summer. 108
Double up Perkel actually work only this particular constructor 109
so this is how we look at a nice string is also getting constructed here. 110
And if the client wants they can actually get the individual values of the additional information. 111
Sophie go back here in let's say the developer wants only the element name so you can do that. 112
You can see just getting anywhere near widgets or so that's about it. 113
That's how we can capture additional information. 114
Our industrial block highly recommends using this particular idiom for capturing additional information 115
. 116
OK. 117
Next we will look at the final item and that's also an interesting item on we would look at it in the 118
next lesson. 119
Thank you.