-
Notifications
You must be signed in to change notification settings - Fork 0
Exceptions
David Sarrut edited this page May 21, 2015
·
6 revisions
(Inspired from: http://www.tiwoc.de/blog/2013/12/globally-handling-uncaught-exceptions-and-signals-in-c)
Exception are thrown with the following macro:
EXCEPTION("My error message in " << filename);
When a function could fail (while accessing a database for example), user can catch the exception and display the message with 'what()', as with standard exceptions. For example:
syd::Database * db;
try {
db = syd::DatabaseManager::GetInstance()->Read(filename);
} catch (syd::Exception & e) {
LOG(FATAL) << e.what();
}
If the exception is not caught by the user, a standard error message is displayed thank to the segmentation signal handler. Main class is sydException.h.