catch (...)
-
Does anyone know of a way to find out what was thrown in a "catch all" catch clause? The app I'm working on throws all sorts of things in addition to exceptions. I hate having to catch each one. e.g. throw TRUE; throw 3; throw ErrObject; Thanks for the help, Bill
-
Does anyone know of a way to find out what was thrown in a "catch all" catch clause? The app I'm working on throws all sorts of things in addition to exceptions. I hate having to catch each one. e.g. throw TRUE; throw 3; throw ErrObject; Thanks for the help, Bill
-
Does anyone know of a way to find out what was thrown in a "catch all" catch clause? The app I'm working on throws all sorts of things in addition to exceptions. I hate having to catch each one. e.g. throw TRUE; throw 3; throw ErrObject; Thanks for the help, Bill
u can combine C++ error handling with C's SEH and u can use SEH to get information abt the exception. Please refer to John Robbins article on SEH and C++ in MSDN Magazine( i forgot the issue ) or his book Ganesh Ramaswamy
-
Does anyone know of a way to find out what was thrown in a "catch all" catch clause? The app I'm working on throws all sorts of things in addition to exceptions. I hate having to catch each one. e.g. throw TRUE; throw 3; throw ErrObject; Thanks for the help, Bill
There's no general way to catch anything throwable inside a
try
block. However, you can consider the possibility of having your app send an object of generic type, this meaning a class capable of holding values of an undetermined type. This beast indeed exists, and has been implemented in Boost any library (hey, it even works with MSVC++ 6.0). If you follow this approach, all you have to do is replace yourthrow
s with:throw bost::any(TRUE);
throw boost::any(3);
throw boost::any(ErrObject);Hope this helps. Joaquín M López Muñoz Telefónica, Ivnestigación y Desarrollo
-
There's no general way to catch anything throwable inside a
try
block. However, you can consider the possibility of having your app send an object of generic type, this meaning a class capable of holding values of an undetermined type. This beast indeed exists, and has been implemented in Boost any library (hey, it even works with MSVC++ 6.0). If you follow this approach, all you have to do is replace yourthrow
s with:throw bost::any(TRUE);
throw boost::any(3);
throw boost::any(ErrObject);Hope this helps. Joaquín M López Muñoz Telefónica, Ivnestigación y Desarrollo
You're probably right about this being the way to go. I was hoping to avoid replacing several hundred assorted throw stmts that are already in the app. Oh well, Guess I'll get to work! :rolleyes: I appreaciate all the responses. Thanks for the help, Bill
-
You're probably right about this being the way to go. I was hoping to avoid replacing several hundred assorted throw stmts that are already in the app. Oh well, Guess I'll get to work! :rolleyes: I appreaciate all the responses. Thanks for the help, Bill
The easiest thing to do is to always throw exceptions using classes that derive from a single "exception" class, similar to how it works in Java. This allows you to always catch any of your exceptions using one
catch(MyBaseException e)
statement. I recommend using the std::exception class as your base class. Regards, Alvaro
-
The easiest thing to do is to always throw exceptions using classes that derive from a single "exception" class, similar to how it works in Java. This allows you to always catch any of your exceptions using one
catch(MyBaseException e)
statement. I recommend using the std::exception class as your base class. Regards, Alvaro
Thanks for the suggestion. I agree that this is the "best" solution. I was hoping to avoid replacing about 1300 throw's in the existing code base. Thanks for the help, Bill