Add an error type for recording failures
This commit is contained in:
parent
103b0eb94d
commit
a2a62554b8
3 changed files with 33 additions and 1 deletions
2
Makefile
2
Makefile
|
@ -2,7 +2,7 @@ CFLAGS ?= -Wall -Wextra -g -O1
|
|||
LDFLAGS ?= -g -O1
|
||||
LIB_CFLAGS ?= -fpic
|
||||
LIB_LDFLAGS ?= -shared
|
||||
GARGOYLE_OBJS := gargoyle scribe sleuth twine
|
||||
GARGOYLE_OBJS := delusion gargoyle scribe sleuth twine
|
||||
GARGOYLE_TEST_OBJS := runner sleuth twine
|
||||
#GARGOYLE_TEST_OBJS := runner $(GARGOYLE_OBJS)
|
||||
|
||||
|
|
19
include/gargoyle/delusion.h
Normal file
19
include/gargoyle/delusion.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef __GARGOYLE_DELUSION_H_
|
||||
#define __GARGOYLE_DELUSION_H_
|
||||
|
||||
#include <gargoyle/codex.h>
|
||||
|
||||
static const uint8_t GARGOYLE_MAX_ERR_SZ = 255;
|
||||
static const uint8_t GARGOYLE_MAX_FUNC_SZ = 32;
|
||||
|
||||
struct gargoyle_err {
|
||||
gargoyle_err_type code;
|
||||
int errno;
|
||||
char func[GARGOYLE_MAX_FUNC_SZ];
|
||||
char errno_func[GARGOYLE_MAX_FUNC_SZ];
|
||||
char msg[GARGOYLE_MAX_ERR_SZ];
|
||||
};
|
||||
|
||||
void gargoyle_emit_err(struct gargoyle_err *err);
|
||||
|
||||
#endif
|
13
src/delusion.c
Normal file
13
src/delusion.c
Normal file
|
@ -0,0 +1,13 @@
|
|||
#include <gargoyle/delusion.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
void gargoyle_emit_err(struct gargoyle_err *err) {
|
||||
fprintf(stderr, "%s(%u): ", err->func, err->code);
|
||||
|
||||
if(err->errno) {
|
||||
fprintf(stderr, "%s(%d): ", err->errno_func, err->errno);
|
||||
}
|
||||
|
||||
fprintf(stderr, "%s\n", err->msg);
|
||||
}
|
Loading…
Reference in a new issue