Provides informative exception handling. More...
#include "RCconfig.h"
#include "Types.h"
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <typeinfo>
Go to the source code of this file.
Classes | |
class | RC::ErrorMsg |
An exception class that records where the exception was thrown and provides a stack trace. More... | |
class | RC::ErrorMsgFatal |
A subtype of RC::ErrorMsg for Fatal errors. More... | |
class | RC::ErrorMsgNull |
A subtype of RC::ErrorMsg for Null errors. More... | |
class | RC::ErrorMsgBounds |
A subtype of RC::ErrorMsg for Bounds errors. More... | |
class | RC::ErrorMsgMemory |
A subtype of RC::ErrorMsg for Memory errors. More... | |
class | RC::ErrorMsgCast |
A subtype of RC::ErrorMsg for Bad Cast errors. More... | |
class | RC::ErrorMsgFile |
A subtype of RC::ErrorMsg for File related errors. More... | |
class | RC::ErrorMsgNet |
A subtype of RC::ErrorMsg for Networking related errors. More... | |
class | RC::Segfault |
A static class for catching and throwing segfaults. More... | |
Namespaces | |
RC | |
Macros | |
#define | RC_MAKE_ERROR_TYPE(Type) |
Creates new RC::ErrorMsg subtypes. More... | |
#define | Throw_RC_Error(err) throw RC::ErrorMsg(err, __FILE__, __LINE__) |
Use this to throw an RC:ErrorMsg exception. More... | |
#define | Throw_RC_Type(Type, err) throw RC::ErrorMsg##Type(err, __FILE__, __LINE__) |
Use this to throw an RC:ErrorMsg subtype exception. More... | |
#define | Catch_RC_Error() catch (RC::ErrorMsgFatal& err) { fprintf(stderr, "Fatal Error: %s\n", err.what()); exit(-1); } catch (RC::ErrorMsg& err) { fprintf(stderr, "Error: %s\n", err.what()); } |
Place after a try block to catch RC errors and print the error text. More... | |
#define | Catch_RC_Error_Exit() catch (RC::ErrorMsg& err) { fprintf(stderr, "Error: %s\n", err.what()); exit(-1); } |
Place after a try block to catch RC errors, print the error text, and exit. | |
Variables | |
const size_t | RC::ErrorMsg_text_size = 4095 |
The maximum size of the char array returned by ErrorMsg::what() and ErrorMsg::GetError(), including the null. | |
const size_t | RC::ErrorMsg_type_bufsize = 256 |
The maximum size of the char array returned by ErrorMsg::GetType(), including the null. | |
Provides informative exception handling.
#define Catch_RC_Error | ( | ) | catch (RC::ErrorMsgFatal& err) { fprintf(stderr, "Fatal Error: %s\n", err.what()); exit(-1); } catch (RC::ErrorMsg& err) { fprintf(stderr, "Error: %s\n", err.what()); } |
Place after a try block to catch RC errors and print the error text.
Note: Exits on ErrorMsgFatal with return value -1.
#define RC_MAKE_ERROR_TYPE | ( | Type | ) |
Creates new RC::ErrorMsg subtypes.
Use as: "namespace RC { RC_MAKE_ERROR_TYPE(NewType) }" to make RC::ErrorMsgNewType
#define Throw_RC_Error | ( | err | ) | throw RC::ErrorMsg(err, __FILE__, __LINE__) |
Use this to throw an RC:ErrorMsg exception.
It automatically adds the source file name and line number.
err | (const char*) The reason for the exception. |
#define Throw_RC_Type | ( | Type, | |
err | |||
) | throw RC::ErrorMsg##Type(err, __FILE__, __LINE__) |
Use this to throw an RC:ErrorMsg subtype exception.
It automatically adds the source file name and line number.
Type | The subtype. e.g. Throw_RC_Type(Null, "Reason") for ErrorMsgNull. |
err | (const char*) The reason for the exception. |