This really is a generic C# question i think, but i thought about it when trying to handle Entity Framework when persisting the data using ObjectContext and specifically SaveChanges()
Now usually i would just follow what the MSDN documentation advises and the appropriate try/catch logic for the required Exceptions. Example is the following for SaveChanges():
http://msdn.microsoft.com/en-us/library/bb336792.aspx
Now im posing this question because reading the above link, there is one Exception listed, called OptimisticConcurrencyException which is fine. Now reading the example they give there is another listed UpdateException. Now I would expect that to be listed within the Exceptions heading.
So going back to the original question, “How to i know all of the exceptions that could be thrown from an Object or their methods”?
Thanks everyone.
Unfortunately I don’t believe you can. However if you look at the inheritance structure of OptimisticConcurrencyException it inherits from:
If you catch
System.Data.DataExceptionit should catch both without having to do a catch-all.