Reputation: 7829
I am catching an ArgumentException
, of which I want a specific property. When I put a breakpoint on the code where the ArgumentException
is caught, I see that it has an ErrorMessage
property:
But trying to access it gives this result:
What's going on here?
Upvotes: 1
Views: 1086
Reputation: 7350
The explanation is that the first screenshot is NOT a stamp of the exceptions internals.
An ArgumentException
has no "ArgumentException" message. This is absolutely sure.
What is the first screenshot referring to? I really don't know, but it seems some sort of service context, already updated with the relevant information.
What you are probably searching for, btw, is the Message
property of the exception.
Upvotes: 0
Reputation: 101150
The problem is that in the first screenshot you display the HttpWebResponse
or similar object, while in the second screenshot you are working with the actual exception.
Exceptions have a Message
property and not an ErrorMessage
. Change the second code to ex.Message
and it will work.
Upvotes: 2