This commit is contained in:
2025-04-07 17:57:06 -05:00
parent 7a3d7a5868
commit a779da6c72
98 changed files with 655 additions and 8974 deletions

60
src/error/error.h Normal file
View File

@@ -0,0 +1,60 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dusk.h"
typedef int32_t errorret_t;
#define ERROR_OK 0
#define ERROR_STACK_SIZE 256
typedef struct {
char_t message[ERROR_STACK_SIZE + 1];
errorret_t code;
} errorstack_t;
extern errorstack_t ERROR_STACK;
/**
* Pushes an error message to the error stack.
*
* @param message Message to push to the error stack.
* @param ... Arguments to format the message with.
*/
errorret_t error(const char_t *message, ...);
/**
* Pushes an error message to the error stack with a given error code.
*
* @param code Error code to push to the error stack.
* @param message Message to push to the error stack.
* @param ... Arguments to format the message with.
*/
errorret_t errorCode(const errorret_t code, const char_t *message, ...);
/**
* Checks if an error has been pushed to the error stack.
*
* @return True if an error has been pushed to the error stack.
*/
bool_t errorCheck();
/**
* Retrieves the error message from the error stack.
*/
const char_t * errorString();
/**
* Clears the error stack.
*/
void errorFlush();
/**
* Prints the error stack to the console. This also clears the error stack.
*/
errorret_t errorPrint();