1. try 2. { 3. 4. AddMenuItem("Item1", Item1Handler); 5. AddMenuItem("Item2", Item2Handler); 6. //... 7. 8. }catch(...) 9. { 10 // Let user know about error 11. }
Item1Handler
void MyClass::Item1Handler() { try { if(smth) throw 11; } catch(someExceptionClass a) { } }
throw 11;
AddItem
try / catch(...)
try / catch (someExceptionClass a)
int
someExceptionClass
void MyClass::Item1Handler() { try { if(smth) throw 11; } catch(...) // handle the correct error here not someExceptionClass { throw // Don't "swallow" the error here, "bubble" it up } }>/pre>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)