The whole thing

This commit is contained in:
Johann Dreo 2014-03-14 21:06:56 +01:00
commit 58afecfa27
3 changed files with 116 additions and 3 deletions

27
example.cpp Normal file
View file

@ -0,0 +1,27 @@
#include <iostream>
#include <iomanip>
#include "exceptions.h"
// Use this macro to build up your hierarchy of exceptions
EXCEPTION( Exception, Existential_Observation );
EXCEPTION( Existential_Observation, Buddhist_Observation );
EXCEPTION( Buddhist_Observation, Zen_Observation );
EXCEPTION( Existential_Observation, Pastafarism_Observation );
int main()
{
try {
double pi = 3.1415926535;
// Use this macro to easily throw an exception with a dynamic message
RAISE( Pastafarism_Observation, std::setprecision(3) << "Shit happens with " << pi << " noodly appendages" );
// Or, if you prefer, use the standard way, but you'll have to indicate E_INFOS yourself
throw( Zen_Observation( "What is the sound of shit happening?", E_INFOS) );
} catch( Existential_Observation & e ) {
std::cerr << e.what() << std::endl;
}
}