void WidgetA::doWork() {
static const char* METHOD_NAME = "doWork";
try {
...
if (<invalid data condition>) {
throw InvalidDataExcep (__FILE__,
METHOD_NAME,
__LINE__,
<err desc text>);
}
...
}
catch (<third party exception>) {
throw <equivalent CommonExcep derived exception>;
}
catch (InvalidDataExcep& anExcep) {
throw;
}
catch(...) {
<either throw exception, or throw UnknownExcep as follows:>
throw UnknownExcep(__FILE__, METHOD_NAME, __LINE__);
}
}
void WidgetB::startWork() {
static const char* METHOD_NAME = "startWork";
try {
...
WidgetA a_widget;
a_widget.doWork();
...
}
catch (<third party exception>) {
throw <equivalent CommonExcep derived exception>;
}
catch (CommonExcep& anExcep) {
anExcep.push(__FILE__, METHOD_NAME, __LINE__);
throw;
}
catch(...) {
<either throw exception, or throw UnknownExcep as follows:>
throw (UnknownExcep(__FILE__, METHOD_NAME, __LINE__));
}
}
main {
try {
...
WidgetB b_widget;
b_widget.startWork();
...
}
catch (CommonExcep& anExcep) {
...
<log exception trace information>
...
}
}
End of Listing