[aspectc-user] Catch exceptions in main()?
Markus Elfring
Markus.Elfring at web.de
Sat Jan 7 19:08:37 CET 2012
> You might be pleased to hear that Puma, AspectC++, and Ag++ are no longer
> compiled with "-fno-exceptions -fno-rtti". AspectC++ and Ag++ now have
> exception handlers in main() (as you proposed).
That is great. - Thanks for your acceptance.
> We evaluated the overhead and found that it is no problem for the Puma library.
Would you like to share a bit more about the involved details which let you
improve the support for exception handling?
How do you think about the appended update suggestion for a bit fine-tuning?
http://stackoverflow.com/questions/2145147/why-catch-an-exception-as-reference-to-const
Would you like to catch the exception "std::bad_alloc" explicitly?
(How many memory will be left over for the current approach of error reporting?)
Regards,
Markus
-------------- next part --------------
Index: ag++.cc
===================================================================
--- ag++.cc (Revision 31)
+++ ag++.cc (Arbeitskopie)
@@ -36,19 +36,17 @@
main(int argc, char **argv)
{
ErrorStream err;
- bool optionsOk;
try {
// Setup Configuration
AGxxConfig config(err, argc, argv);
- optionsOk = config.analyze();
-
if (config.verbose() > 0)
{
config.printOptions();
}
- if (!optionsOk)
+
+ if (!config.analyze())
{
return EXIT_FAILURE;
}
@@ -132,15 +130,16 @@
++opt;
}
}
+
+ return EXIT_SUCCESS;
}
- catch (std::exception &e) {
+ catch (std::exception const & e) {
err << sev_fatal << "Caught standard exception: " << e.what () << endMessage;
- return EXIT_FAILURE;
}
catch (...) {
err << sev_fatal << "Caught unknown exception!" << endMessage;
- return EXIT_FAILURE;
}
- return EXIT_SUCCESS;
+
+ return EXIT_FAILURE;
}
-------------- next part --------------
Index: ac++.cc
===================================================================
--- ac++.cc (Revision 147)
+++ ac++.cc (Arbeitskopie)
@@ -43,7 +43,7 @@
// Weave the AspectC++ code
ac.weave ();
}
- catch (std::exception &e) {
+ catch (std::exception const & e) {
err << sev_fatal << "Caught standard exception: " << e.what () << endMessage;
}
catch (...) {
More information about the aspectc-user
mailing list