hydroforth/src/hydroforth/result.c
2023-08-04 21:42:01 +02:00

26 lines
564 B
C

#include "ansi_lib.h"
#include <stdio.h>
#include <stdlib.h>
#include "hydroforth/hydroforth.h"
void hf__print_error(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);
}