2022-06-30 07:30:34 +00:00
|
|
|
#include <gargoyle/delusion.h>
|
2022-07-01 17:41:50 +00:00
|
|
|
#include <gargoyle/twine.h>
|
|
|
|
#include <stdarg.h>
|
2022-06-30 07:30:34 +00:00
|
|
|
#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);
|
|
|
|
}
|
2022-07-01 17:41:50 +00:00
|
|
|
|
|
|
|
void gargoyle_fill_err(struct gargoyle_err *err, gargoyle_err_type code, int errno_code, const char *func, const char *errno_func, const char *fmt, ...) {
|
|
|
|
err->code = code;
|
|
|
|
err->errno = errno_code;
|
|
|
|
|
|
|
|
|
|
|
|
if(func) {
|
|
|
|
gargoyle_cpy(err->func, func, GARGOYLE_MAX_FUNC_SZ, GARGOYLE_FLG_FILL0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(errno_func) {
|
|
|
|
gargoyle_cpy(err->errno_func, errno_func, GARGOYLE_MAX_FUNC_SZ, GARGOYLE_FLG_FILL0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(fmt) {
|
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
vsnprintf(err->msg, GARGOYLE_MAX_ERR_SZ, fmt, args);
|
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
}
|