infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
Error Reporting

Public structures and enumerations for detailed error reporting. More...

Collaboration diagram for Error Reporting:

Classes

struct  infix_error_details_t
 A structure holding detailed information about the last error that occurred on the current thread. More...
 

Enumerations

enum  infix_error_category_t {
  INFIX_CATEGORY_NONE , INFIX_CATEGORY_GENERAL , INFIX_CATEGORY_ALLOCATION , INFIX_CATEGORY_PARSER ,
  INFIX_CATEGORY_ABI
}
 Broad categories for errors that can occur in the library. More...
 
enum  infix_error_code_t {
  INFIX_CODE_SUCCESS = 0 , INFIX_CODE_UNKNOWN , INFIX_CODE_OUT_OF_MEMORY = 100 , INFIX_CODE_EXECUTABLE_MEMORY_FAILURE ,
  INFIX_CODE_PROTECTION_FAILURE , INFIX_CODE_UNEXPECTED_TOKEN = 200 , INFIX_CODE_UNTERMINATED_AGGREGATE , INFIX_CODE_INVALID_KEYWORD ,
  INFIX_CODE_MISSING_RETURN_TYPE , INFIX_CODE_INTEGER_OVERFLOW , INFIX_CODE_RECURSION_DEPTH_EXCEEDED , INFIX_CODE_EMPTY_MEMBER_NAME ,
  INFIX_CODE_UNSUPPORTED_ABI = 300 , INFIX_CODE_TYPE_TOO_LARGE , INFIX_CODE_UNRESOLVED_NAMED_TYPE , INFIX_CODE_INVALID_MEMBER_TYPE ,
  INFIX_CODE_LIBRARY_NOT_FOUND = 400 , INFIX_CODE_SYMBOL_NOT_FOUND , INFIX_CODE_LIBRARY_LOAD_FAILED
}
 Specific error codes providing detailed information about a failure. More...
 

Functions

infix_error_details_t infix_get_last_error (void)
 Retrieves detailed information about the last error that occurred on the current thread.
 

Detailed Description

Public structures and enumerations for detailed error reporting.

Enumeration Type Documentation

◆ infix_error_category_t

Broad categories for errors that can occur in the library.

Enumerator
INFIX_CATEGORY_NONE 

No error.

INFIX_CATEGORY_GENERAL 

A general or miscellaneous error.

INFIX_CATEGORY_ALLOCATION 

An error related to memory allocation.

INFIX_CATEGORY_PARSER 

An error that occurred while parsing a signature string.

INFIX_CATEGORY_ABI 

An error related to ABI classification or JIT generation.

◆ infix_error_code_t

Specific error codes providing detailed information about a failure.

This enumeration provides fine-grained details about why an operation failed. It is designed to be used in conjunction with infix_get_last_error() to enable robust, programmatic error handling and clear diagnostic messages.

Enumerator
INFIX_CODE_SUCCESS 

The operation completed successfully.

INFIX_CODE_UNKNOWN 

An unknown or unspecified error occurred. This is a fallback code.

INFIX_CODE_OUT_OF_MEMORY 

Failure to allocate memory. Likely due to lack of system resources.

INFIX_CODE_EXECUTABLE_MEMORY_FAILURE 

Failed to allocate memory for JIT compiler. Check system_error_code.

INFIX_CODE_PROTECTION_FAILURE 

Failed to change memory protection flags. Check system_error_code.

INFIX_CODE_UNEXPECTED_TOKEN 

Parser ran into an invalid character at a given position.

INFIX_CODE_UNTERMINATED_AGGREGATE 

A {...}, <...>, or [...] was not properly closed.

INFIX_CODE_INVALID_KEYWORD 

Parser found an unknown keyword (e.g., "integer" instead of "int").

INFIX_CODE_MISSING_RETURN_TYPE 

A function signature was missing the -> or a return type.

INFIX_CODE_INTEGER_OVERFLOW 

An integer overflow was detected, typically when calculating the size of a very large array or struct.

INFIX_CODE_RECURSION_DEPTH_EXCEEDED 

The parser exceeded the max nesting depth (e.g., {{{{...}}}}).

INFIX_CODE_EMPTY_MEMBER_NAME 

A named type was declared with empty angle brackets, such as struct<>.

INFIX_CODE_UNSUPPORTED_ABI 

infix doesn't (yet?) have an implementation for the requested ABI.

INFIX_CODE_TYPE_TOO_LARGE 

A type was too large to be handled by the ABI.

INFIX_CODE_UNRESOLVED_NAMED_TYPE 

The type graph that contains an unresolved named reference.

INFIX_CODE_INVALID_MEMBER_TYPE 

An aggregate contained an illegal member type (e.g., {int, void})

INFIX_CODE_LIBRARY_NOT_FOUND 

The requested lib could not be found or loaded. Check the message field.

INFIX_CODE_SYMBOL_NOT_FOUND 

The requested symbol could not be found within the lib.

INFIX_CODE_LIBRARY_LOAD_FAILED 

Loading the lib failed for a reason other. Check message and system_error_code

Function Documentation

◆ infix_get_last_error()

infix_error_details_t infix_get_last_error ( void  )

Retrieves detailed information about the last error that occurred on the current thread.

This function is thread-safe. Each thread maintains its own error state. A successful API call will reset the error state for the current thread.

Returns
An infix_error_details_t struct containing the details of the last error. If no error has occurred since the last successful operation, the category will be INFIX_CATEGORY_NONE and the code will be INFIX_CODE_SUCCESS.
infix_type* type = NULL;
infix_status status = infix_type_from_signature(&type, &arena, "{int, ^float}", nullptr); // Invalid token '^'
fprintf(stderr, "Parser error: %d at position %zu\n", err.code, err.position);
// Prints: Parser error: 3 at position 7
}
infix_arena_t * arena
Definition 005_layouts.c:57
infix_status status
Definition 103_unions.c:74
infix_error_details_t infix_get_last_error(void)
Retrieves detailed information about the last error that occurred on the current thread.
Definition error.c:87
c23_nodiscard infix_status infix_type_from_signature(infix_type **, infix_arena_t **, const char *, infix_registry_t *)
Parses a signature string representing a single data type.
Definition signature.c:1090
infix_status
An enumeration of all possible success or failure codes from the public API.
Definition infix.h:351
@ INFIX_SUCCESS
The operation completed successfully.
Definition infix.h:352
Definition infix_internals.h:130
A structure holding detailed information about the last error that occurred on the current thread.
Definition infix.h:1093
size_t position
For parser errors, the 0-based index in the input string where the error occurred.
Definition infix.h:1096
infix_error_code_t code
The specific error code.
Definition infix.h:1095
The central structure for describing any data type in the FFI system.
Definition infix.h:161

Retrieves detailed information about the last error that occurred on the current thread.