Reduct  v4.0.5-1-g4851deb
A functional and immutable language.
Loading...
Searching...
No Matches
error.h File Reference

Error handling and reporting. More...

#include <reduct/defs.h>
#include <assert.h>
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
Include dependency graph for error.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  reduct_error_frame_t
 Backtrace frame structure. More...
 
struct  reduct_error_t
 Error structure. More...
 

Macros

#define REDUCT_ERROR_MAX_LEN   128
 Maximum length of an error string.
 
#define REDUCT_ERROR_BACKTRACE_MAX   8
 Maximum number of backtrace frames.
 
#define REDUCT_ERROR()   ((reduct_error_t){0})
 Create a Reduct error structure.
 
#define REDUCT_ERROR_GENERIC(_reduct, _error, _item, _type, ...)
 Throw an error using the jump buffer in the error structure.
 
#define REDUCT_ERROR_SUCCESS(_error)   ((_error)->type == REDUCT_ERROR_TYPE_NONE)
 Check if an error structure indicates a successful operation.
 
#define REDUCT_ERROR_CATCH(_error)   (setjmp((_error)->jmp))
 Catch an error using the jump buffer in the error structure.
 
#define REDUCT_ERROR_TRY(_reduct, _error)
 Execute a block of code safely, catching any Reduct errors.
 
#define REDUCT_ERROR_THROW(_reduct, ...)   reduct_error_throw_runtime((_reduct), __VA_ARGS__)
 Throw a runtime error using the jump buffer in the error structure.
 
#define REDUCT_ERROR_RETHROW(_reduct, _error)   REDUCT_ERROR_THROW(_reduct, "%s", (_error)->message);
 Rethrow an existing error.
 
#define REDUCT_ERROR_ASSERT(_reduct, _expr, ...)
 Throw a runtime error if the expression is false.
 
#define REDUCT_ERROR_SYNTAX(_error, _input, _ptr, ...)
 Throw a syntax error using the jump buffer in the error structure.
 
#define REDUCT_ERROR_COMPILE(_compiler, _handle, ...)
 Throw a compile error using the jump buffer in the error structure.
 
#define REDUCT_ERROR_COMPILE_LAST(_compiler, ...)
 Throw a compile error using the jump buffer in the error structure using the last item process by the compiler.
 
#define REDUCT_ERROR_COMPILE_ASSERT(_compiler, _expr, ...)
 Throw a compile error if the expression is false.
 
#define REDUCT_ERROR_INTERNAL(_reduct, ...)   REDUCT_ERROR_GENERIC(_reduct, (_reduct)->error, NULL, INTERNAL, __VA_ARGS__)
 Throw an internal error using the jump buffer in the error structure.
 

Enumerations

enum  reduct_error_type_t {
  REDUCT_ERROR_TYPE_NONE , REDUCT_ERROR_TYPE_SYNTAX , REDUCT_ERROR_TYPE_COMPILE , REDUCT_ERROR_TYPE_RUNTIME ,
  REDUCT_ERROR_TYPE_INTERNAL
}
 Error type enumeration. More...
 

Functions

REDUCT_API void reduct_error_print (reduct_error_t *error, FILE *file)
 Format and print the error to a file.
 
REDUCT_API void reduct_error_get_row_column (reduct_error_t *error, size_t *row, size_t *column)
 Get the row and column by traversing the input buffer.
 
REDUCT_API void reduct_error_set (reduct_error_t *error, const char *path, const char *input, size_t inputLength, size_t regionLength, size_t position, reduct_error_type_t type, const char *message,...)
 Set the error information in the error structure.
 
REDUCT_API void reduct_error_get_item_params (struct reduct *reduct, struct reduct_item *item, const char **path, const char **input, size_t *inputLength, size_t *regionLength, size_t *position)
 Get the error parameters from a Reduct item.
 
REDUCT_API REDUCT_NORETURN void reduct_error_throw_runtime (struct reduct *reduct, const char *message,...)
 Throw a runtime error utilizing the evaluation state to determine the context.
 
REDUCT_API void reduct_error_push (struct reduct *reduct, reduct_error_t *error)
 Push a new error handler onto the stack.
 
REDUCT_API void reduct_error_pop (struct reduct *reduct)
 Pop the current error handler from the stack.
 

Detailed Description

Error handling and reporting.

Definition in file error.h.