2023-12-09 17:24:41 +00:00
|
|
|
#ifndef RZ_ERR_H
|
|
|
|
#define RZ_ERR_H
|
|
|
|
|
|
|
|
#define RZ_ERROR_STACK_SIZE 256
|
|
|
|
|
|
|
|
#include "commons.h"
|
|
|
|
|
2023-12-11 17:01:22 +00:00
|
|
|
#define ERR_TYPES(G) \
|
|
|
|
G(ERR_WARNING), G(ERR_FATAL)
|
|
|
|
|
|
|
|
RZ_ENUM_H(ErrType, ERR_TYPES);
|
|
|
|
|
2023-12-09 17:24:41 +00:00
|
|
|
typedef struct {
|
2023-12-11 17:01:22 +00:00
|
|
|
ErrType type;
|
2023-12-09 17:24:41 +00:00
|
|
|
char* what;
|
|
|
|
int line;
|
|
|
|
} err_msg_t;
|
|
|
|
|
|
|
|
typedef struct {
|
2023-12-17 18:10:17 +00:00
|
|
|
int total;
|
|
|
|
int quiet;
|
2023-12-09 17:24:41 +00:00
|
|
|
size_t size;
|
|
|
|
err_msg_t* errors[RZ_ERROR_STACK_SIZE];
|
|
|
|
} err_t;
|
|
|
|
|
|
|
|
void err_init(err_t* err);
|
|
|
|
void err_free(err_t* err);
|
|
|
|
|
2023-12-11 17:01:22 +00:00
|
|
|
void err_of_type(err_t* err, char* what, int line, ErrType type);
|
|
|
|
void err_fatal(err_t* err, char* what, int line);
|
|
|
|
|
|
|
|
int err_dump(err_t* err);
|
2023-12-09 17:24:41 +00:00
|
|
|
|
|
|
|
#endif
|