Nilorea Library exception api test.
int array_exception( int boolean )
{
if( boolean )
{
}
return 1 ;
}
int divzero_exception( int boolean )
{
if( boolean )
{
}
return 1 ;
}
int overflow_exception( int boolean )
{
if( boolean )
{
}
return 1 ;
}
int parsing_exception( int boolean )
{
if( boolean )
{
}
return 1 ;
}
int all_exception( int boolean )
{
if( boolean )
{
}
return 1 ;
}
int main( void )
{
puts( "ArrayNoCatch" );
{
array_exception( 0 );
array_exception( 1 );
}
puts( "ArrayCatch" );
{
array_exception( 0 );
array_exception( 1 );
}
{
}
puts( "DivZeroNoCatch" );
{
divzero_exception( 0 );
divzero_exception( 1 );
}
puts( "DivZeroCatch" );
{
divzero_exception( 0 );
divzero_exception( 1 );
}
{
}
{
overflow_exception( 0 );
overflow_exception( 1 );
}
{
overflow_exception( 0 );
overflow_exception( 1 );
}
{
}
{
parsing_exception( 0 );
parsing_exception( 1 );
}
{
parsing_exception( 0 );
parsing_exception( 1 );
}
{
}
{
all_exception( 0 );
all_exception( 1 );
}
{
all_exception( 0 );
all_exception( 1 );
}
{
}
{
n_log(
LOG_NOTICE,
"Trying mixed Try-Catch blocks, we are inside block 1" );
{
}
{
n_log(
LOG_NOTICE,
"Caught signal matching GENERAL_EXCEPTION inside block 2" );
}
}
{
n_log(
LOG_NOTICE,
"Caught signal matching GENERAL_EXCEPTION inside block 1" );
}
exit( 0 );
}
#define Throw(X)
Macro helper for adding exception throwing in custom functions.
#define OVERFLOW_EXCEPTION
Possibly Throwed value, we checked an overflow in our arrays.
#define Try
Macro for replacing try.
#define GENERAL_EXCEPTION
General exception, we just detected an error an decided to go back where we're safe.
#define PARSING_EXCEPTION
Possibly Throwed value, we checked an error during a char * parsing.
#define ARRAY_EXCEPTION
Possibly Throwed value, we checked an out of bound operation.
#define Catch(X)
Macro for replacing catch.
#define DIVZERO_EXCEPTION
Possibly Throwed value, we check a divide by zero operation.
#define EndTry
Macro helper for closing the try-catch block.
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_DEBUG
debug-level messages
#define LOG_STDERR
internal, default LOG_TYPE
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL )
#define LOG_NOTICE
normal but significant condition
#define LOG_INFO
informational
Exception management for C.