ssm
0.0.2
Runtime Library for the Sparse Synchronous Model
|
The SSM_THROW() macro is used to throw unrecoverable runtime errors. More...
The SSM_THROW() macro is used to throw unrecoverable runtime errors.
SSM_THROW() calls the underlying ssm_throw() function with information about where in the source code the error was encountered. Because each platform may have different error-handling and logging capabilities, this library requires that the ssm_throw() symbol to be defined externally, typically by platform-specific bindings.
Any definition of ssm_throw() should not be expected to return; otherwise, the behavior of subsequently interacting with the runtime library becomes undefined. For example, a platform-independent definition of ssm_throw() may just spin indefinitely, though this does not provide very helpful feedback for debugging:
A more sensible definition might call exit(), perhaps after logging some relevant information using the provided arguments:
Macros | |
#define | SSM_ASSERT(cond) |
Throw an internal error. More... | |
#define | SSM_THROW(reason) ssm_throw(reason, __FILE__, __LINE__, __func__) |
Terminate due to a non-recoverable error, with a specified reason. More... | |
Typedefs | |
typedef enum ssm_error | ssm_error_t |
Error codes indicating reason for failure. More... | |
Enumerations | |
enum | ssm_error { SSM_INTERNAL_ERROR = 1 , SSM_EXHAUSTED_ACT_QUEUE , SSM_EXHAUSTED_EVENT_QUEUE , SSM_EXHAUSTED_MEMORY , SSM_EXHAUSTED_PRIORITY , SSM_NOT_READY , SSM_INVALID_TIME , SSM_INVALID_MEMORY , SSM_PLATFORM_ERROR } |
Error codes indicating reason for failure. More... | |
Functions | |
void | ssm_throw (ssm_error_t reason, const char *file, int line, const char *func) |
Underlying exception handler; must be overridden by each platform. More... | |
#define SSM_ASSERT | ( | cond | ) |
Throw an internal error.
cond | the condition to assert. |
Definition at line 23 of file ssm-internal.h.
#define SSM_THROW | ( | reason | ) | ssm_throw(reason, __FILE__, __LINE__, __func__) |
Terminate due to a non-recoverable error, with a specified reason.
Invoked when a process must terminate, e.g., when memory or queue space is exhausted. Not expected to terminate.
Wraps the underlying ssm_throw() exception handler, passing along the file name, line number, and function name in the source file where the error was thrown.
reason | an ssm_error_t specifying the reason for the error. |
typedef enum ssm_error ssm_error_t |
Error codes indicating reason for failure.
Platforms may extend the list of errors using SSM_PLATFORM_ERROR like this:
enum ssm_error |
Error codes indicating reason for failure.
Platforms may extend the list of errors using SSM_PLATFORM_ERROR like this:
void ssm_throw | ( | ssm_error_t | reason, |
const char * | file, | ||
int | line, | ||
const char * | func | ||
) |
Underlying exception handler; must be overridden by each platform.
This is left undefined by the SSM runtime for portability. On platforms where exit() is available, that may be used. Where possible, an exception handler may also log additional information using the given parameters for better debuggability.
reason | an ssm_error_t specifying the reason for the error. |
file | the file name of the source file where the error was thrown. |
line | the line number of the source file where the error was thrown. |
func | the function name where the error was thrown. |