Determining exception type after the exception is caught?

前端 未结 9 1299
梦毁少年i
梦毁少年i 2020-12-01 01:20

Is there a way to determine the exception type even know you caught the exception with a catch all?

Example:

try
{
   SomeBigFunction();
}
catch(...)         


        
9条回答
  •  余生分开走
    2020-12-01 02:09

    If you need to handle exceptions differently based on what they are, you should be catching specific exceptions. If there are groups of exceptions that all need to be handled identically, deriving them from a common base class and catching the base class would be the way to go. Leverage the power and paradigms of the language, don't fight against them!

提交回复
热议问题