This commit is contained in:
2025-06-08 14:38:22 -05:00
parent 8411c2981b
commit 0b6b33721b
69 changed files with 210 additions and 3384 deletions

View File

@@ -1,56 +0,0 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "error.h"
errorstack_t ERROR_STACK;
errorret_t error(const char_t *message, ...) {
return errorCode(1, message);
}
errorret_t errorCode(const errorret_t code, const char_t *message, ...) {
if(ERROR_STACK.code != ERROR_OK) {
snprintf(
ERROR_STACK.message,
ERROR_STACK_SIZE,
"Multiple errors encountered."
);
errorPrint();
return code;
}
va_list args;
va_start(args, message);
vsnprintf(ERROR_STACK.message, ERROR_STACK_SIZE, message, args);
va_end(args);
return ERROR_STACK.code = code;
}
bool_t errorCheck() {
return ERROR_STACK.code != ERROR_OK;
}
const char_t * errorString() {
if(!errorCheck()) return NULL;
return ERROR_STACK.message;
}
void errorFlush() {
if(!errorCheck()) return;
ERROR_STACK.code = ERROR_OK;
ERROR_STACK.message[0] = '\0';
}
errorret_t errorPrint() {
if(!errorCheck()) return ERROR_OK;
printf("Error: %s\n", errorString());
errorret_t code = ERROR_STACK.code;
errorFlush();
return code;
}