|
Serene Runtime 1.0.0-dev
C runtime for the Serene programming language
|
#include "serene/rt/errors.h"#include <stdio.h>#include "serene/rt/context.h"#include "serene/utils.h"#include "serene/utils/srn_dbg_sym.h"Go to the source code of this file.
Functions | |
| static const char * | srn_error_tag_name (srn_error_tag_t tag) |
| char * | srn_error_to_string (const srn_context_t *ctx, const srn_error_t *err) |
| Format err as a newly allocated string of the form [TAG]: msg, allocated in ctx. | |
| void | srn_error_trace_push (const srn_context_t *ctx, srn_error_t *err, void *addr) |
| Append a return address to the trace of a runtime-layer error. | |
| srn_error_t * | srn_errors_make (const srn_context_t *ctx, srn_error_tag_t tag, const char *msg, void *caller) |
| Build an error in ctx's memory, tagged tag and carrying msg. | |
| srn_error_t * | srn_errors_from (const srn_context_t *ctx, const srn_error_t *src, void *caller) |
| Build an error in ctx's memory that carries the layer, tag, message and payload of src, with a trace of its own that starts at caller. | |
| void * | srn_errors_fail (const srn_context_t *ctx, size_t size, size_t alignment, srn_error_tag_t tag, const char *msg, void *caller) |
| Allocate a size/alignment value in ctx, set its ERROR_HEADER (the first member, srn_error_t *maybe_error) to a fresh error, and return it. | |
|
static |
Definition at line 36 of file errors.c.
|
nodiscard |
Format err as a newly allocated string of the form [TAG]: msg, allocated in ctx.
Returns [UNKNOWN]: <null> when err is null.
Definition at line 133 of file errors.c.
| void srn_error_trace_push | ( | const srn_context_t * | ctx, |
| srn_error_t * | err, | ||
| void * | addr ) |
Append a return address to the trace of a runtime-layer error.
Allocates frames from ctx on the first call. Silently does nothing when the trace is full or the error is not a runtime-layer error.
Definition at line 177 of file errors.c.
|
nodiscard |
Allocate a size/alignment value in ctx, set its ERROR_HEADER (the first member, srn_error_t *maybe_error) to a fresh error, and return it.
The result is a valid fallible value whose HAS_ERROR is true. Use the FAIL macro, which fills in size/alignment from the target type.
Definition at line 224 of file errors.c.
| srn_error_t * srn_errors_from | ( | const srn_context_t * | ctx, |
| const srn_error_t * | src, | ||
| void * | caller ) |
Build an error in ctx's memory that carries the layer, tag, message and payload of src, with a trace of its own that starts at caller.
src is not written to, so this is the way to take a trace on an error that is shared or immutable, such as the reactor's static IO errors. A runtime layer src with frames has them copied, so the earlier trace is kept. The ERR_FROM macro supplies caller.
Definition at line 207 of file errors.c.
| srn_error_t * srn_errors_make | ( | const srn_context_t * | ctx, |
| srn_error_tag_t | tag, | ||
| const char * | msg, | ||
| void * | caller ) |
Build an error in ctx's memory, tagged tag and carrying msg.
caller is the return address of the call site (pass __builtin_return_address(0)) and is recorded as the first frame of the trace. The ERR macro supplies it automatically.
Definition at line 196 of file errors.c.