Basic error handling

This commit is contained in:
Wilson Lin 2018-07-04 23:24:32 +12:00
parent a818e4f95a
commit a73b3aee5b
1 changed files with 20 additions and 0 deletions

20
src/main/c/error/error.c Normal file
View File

@ -0,0 +1,20 @@
#ifndef _HDR_HYPERBUILD_ERROR
#define _HDR_HYPERBUILD_ERROR
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
void hbe_fatal(char *fmt, ...) {
va_list args;
va_start(args, fmt);
fprintf(stderr, "[FATAL] hyperbuild encountered an error:\n");
vfprintf(stderr, fmt, args);
printf("\n");
va_end(args);
exit(EXIT_FAILURE);
}
// TODO errcode enum used as exit statuses
#endif // _HDR_HYPERBUILD_ERROR