hydroforth/src/hydroforth/result.c
Dominic Grimm 7490439223
All checks were successful
continuous-integration/drone/push Build is passing
Add error call stack if call stack exceeds maximum capacity
2023-08-05 20:19:52 +02:00

31 lines
647 B
C

#include "ansi_lib.h"
#include <stdio.h>
#include <stdlib.h>
#include "hydroforth/hydroforth.h"
void hf__handle_error_light(struct hf__error_wrapper *error) {
SET_8_VALUE_COLOUR(TXT_RED);
printf("Error: %s", HF__ERROR_STR[error->error]);
if (error->msg) {
printf(": ");
SET_8_VALUE_COLOUR(TXT_GREEN);
printf("%s", error->msg);
SET_8_VALUE_COLOUR(TXT_RED);
if (error->msg_is_freeable) {
free(error->msg);
}
}
putchar(' ');
SET_8_VALUE_COLOUR(TXT_YELLOW);
printf("[0x%x]", error->error);
SET_8_VALUE_COLOUR(TXT_DEFAULT);
if (HF__ERROR_PANIC[error->error]) {
putchar('\n');
exit(1);
}
}