commit asset prog

This commit is contained in:
2025-08-26 16:23:08 -05:00
parent 8af2f044ed
commit a543bc7c00
11 changed files with 244 additions and 126 deletions

View File

@@ -21,15 +21,15 @@ typedef struct {
errorstate_t *state;
} errorret_t;
static const errorcode_t ERROR_OK = 0;
static const errorcode_t ERROR_NOT_OK = 1;
#define ERROR_STATE_INIT ((errorstate_t){ ERROR_OK, NULL, NULL })
static const char_t *ERROR_PRINT_FORMAT = "Error (%d): %s\n%s";
static const char_t *ERROR_LINE_FORMAT = " at %s:%d in function %s\n";
static errorstate_t ERROR_STATE = {
.code = ERROR_OK,
.message = NULL,
.lines = NULL
};
static errorstate_t ERROR_STATE = ERROR_STATE_INIT;
/**
* Sets the error state with the provided code and message.
@@ -91,6 +91,34 @@ void errorCatch(const errorret_t retval);
*/
errorret_t errorPrint(const errorret_t retval);
/**
* Creates an error with a specific error state.
*
* @param state The error state to set.
* @param message The format string for the error message.
* @param ... Additional arguments for the format string.
* @return The error code.
*/
#define errorCreate(state, message, ... ) \
errorThrowImpl(\
(state), ERROR_NOT_OK, __FILE__, __func__, __LINE__, (message), \
##__VA_ARGS__ \
)
/**
* Throws an error with a specific error state.
*
* @param state The error state to set.
* @param message The format string for the error message.
* @param ... Additional arguments for the format string.
* @return The error code.
*/
#define errorThrowState(state, message, ... ) \
return errorThrowImpl(\
(state), ERROR_NOT_OK, __FILE__, __func__, __LINE__, (message), \
##__VA_ARGS__ \
)
/**
* Throws an error with a formatted message.
*