EXCEPTIONS: C++ style try,catch,endtry,throw
Structures
| Name | |
|---|---|
| struct | ExceptionContextList Exception stack structure. |
Functions
| Name | |
|---|---|
| void | push_exception(void ) add an exception context to the stack |
| void | pop_exception(int ex) pop an exception context from the stack |
Attributes
| Name | |
|---|---|
| __thread ExceptionContextList * | __Exceptions Globale variable for exception stack management. |
Defines
| Name | |
|---|---|
| Try Macro for replacing try. |
|
| Throw(X) Macro helper for adding exception throwing in custom functions. |
|
| PARSING_EXCEPTION Possibly Throwed value, we checked an error during a char * parsing. |
|
| OVERFLOW_EXCEPTION Possibly Throwed value, we checked an overflow in our arrays. |
|
| NO_EXCEPTION Possibly Throwed value, everything is fine. |
|
| GENERAL_EXCEPTION General exception, we just detected an error an decided to go back where we're safe. |
|
| EndTry Macro helper for closing the try-catch block. |
|
| DIVZERO_EXCEPTION Possibly Throwed value, we check a divide by zero operation. |
|
| CatchAll() Macro for replacing catch. |
|
| Catch(X) Macro for replacing catch. |
|
| ARRAY_EXCEPTION Possibly Throwed value, we checked an out of bound operation. |
Functions Documentation
function push_exception
void push_exception(
void
)
add an exception context to the stack
Function to push an exception in the list.
add an exception context to the stack
function pop_exception
void pop_exception(
int ex
)
pop an exception context from the stack
Parameters:
- ex Type of exception to pop
Function to pop an exception in the list.
pop an exception context from the stack
Attributes Documentation
variable __Exceptions
__thread ExceptionContextList * __Exceptions;
Globale variable for exception stack management.
Macros Documentation
define Try
#define Try { \
volatile int __exc_; \
push_exception(); \
__exc_ = setjmp(__Exceptions->context); \
if (__exc_ == NO_EXCEPTION) {
Macro for replacing try.
define Throw
#define Throw(
X
)
do { \
int __exc_val_ = (X); \
n_log(LOG_ERR, "Exception thrown: %d", __exc_val_); \
if (__Exceptions) { \
longjmp(__Exceptions->context, __exc_val_ ? __exc_val_ : 1); \
} else { \
n_log(LOG_ERR, "Throw called outside Try block!"); \
abort(); \
} \
} while (0)
Macro helper for adding exception throwing in custom functions.
Note: longjmp with value 0 is replaced with 1 by the C standard, so Throw(NO_EXCEPTION) would actually trigger a catch. Avoid it.
define PARSING_EXCEPTION
#define PARSING_EXCEPTION 16
Possibly Throwed value, we checked an error during a char * parsing.
define OVERFLOW_EXCEPTION
#define OVERFLOW_EXCEPTION 8
Possibly Throwed value, we checked an overflow in our arrays.
define NO_EXCEPTION
#define NO_EXCEPTION 0
Possibly Throwed value, everything is fine.
define GENERAL_EXCEPTION
#define GENERAL_EXCEPTION (ARRAY_EXCEPTION | DIVZERO_EXCEPTION | OVERFLOW_EXCEPTION | PARSING_EXCEPTION)
General exception, we just detected an error an decided to go back where we're safe.
define EndTry
#define EndTry } \
pop_exception(__exc_); \
}
Macro helper for closing the try-catch block.
define DIVZERO_EXCEPTION
#define DIVZERO_EXCEPTION 4
Possibly Throwed value, we check a divide by zero operation.
define CatchAll
#define CatchAll(
)
} \
if (__exc_ != 0) { \
__exc_ = 0;
Macro for replacing catch.
define Catch
#define Catch(
X
)
} \
if (__exc_ & (X)) { \
__exc_ = 0;
Macro for replacing catch.
define ARRAY_EXCEPTION
#define ARRAY_EXCEPTION 2
Possibly Throwed value, we checked an out of bound operation.
Modules
- AABB3D
- ACCEPT_POOL
- ALLEGRO4
- ALLEGRO5
- ANIM_LIB
- ASTAR
- ATLAS_LIB
- AVRO
- CLOCK_SYNC
- COMMONS
- CONFIGFILE
- CYPHER_BASE64
- CYPHER_VIGENERE
- DEAD_RECKONING
- ENUMS
- EXCEPTIONS
- GAME_ENV
- GIT
- GUI
- HASH_TABLE
- ISOMETRIC_ENGINE
- LIST
- LOG
- LOGNODUP
- LZ4
- NETWORKING
- NETWORK_MSG
- N_COOKIES
- N_DIFF
- N_DIGEST
- N_DISK_CACHE
- N_DNS
- N_ECC
- N_ENTROPY
- N_FILES
- N_FLUIDS
- N_GUI_COLOR
- N_GUI_COLORWHEEL
- N_GUI_CURVE
- N_GUI_GRID
- N_GUI_POPUP
- N_HEX
- N_HTTP3
- N_HTTP_COOKIE
- N_HTTP_FORM
- N_HTTP_MIME
- N_HTTP_REQ
- N_HTTP_RESP
- N_HTTP_ROUTER
- N_HTTP_SERVER
- N_ICC
- N_JSON
- N_KAFKA
- N_LINALG
- N_MODULE
- N_OPENSSL_COMPAT
- N_PRETTY
- N_PTH
- N_QUERY
- N_RANDOM
- N_SHA256
- N_STR
- N_TIFF
- N_TIME
- N_USER
- N_X509
- N_ZIP
- PARTICLES
- PCRE
- PHYSICS
- SIGNALS
- STACK
- THREADS
- TRAJECTORY
- TREE
- ZLIB