Types of exceptions
C#
2
Posts
2
Posters
0
Views
1
Watching
-
hello is there any way to determine what exception has been thrown ? i have a try and catch block catching Exception all the time, but id like to know what type of Exception is thrown for an object that throws one, so i know what to catch.
The documentation should tell you what exceptions to expect, but you can get the name by doing the following
catch(Exception e) {
string name = e.GetType().Name;
Console.WriteLine("Exception: {0}", name);
}Or just take the catch out altogether and the framework will catch it, in the description it should give the name of the exception. James Sonork ID: 100.11138 - Hasaki "My words but a whisper -- your deafness a SHOUT. I may make you feel but I can't make you think." - Thick as a Brick, Jethro Tull 1972