fixed error message generation
This commit is contained in:
@@ -5,13 +5,13 @@
|
||||
|
||||
typedef struct ErrorCallPos {
|
||||
i32 line;
|
||||
str file;
|
||||
str func;
|
||||
cstr file;
|
||||
cstr func;
|
||||
} ErrorCallPos;
|
||||
#define ErrorCallPos_here() (ErrorCallPos){\
|
||||
.line = __LINE__,\
|
||||
.file = str_construct((char*)(void*)__FILE__, sizeof(__FILE__), true),\
|
||||
.func = str_construct((char*)(void*)__func__, sizeof(__func__), true)\
|
||||
.file = __FILE__,\
|
||||
.func = __func__\
|
||||
}
|
||||
|
||||
typedef struct Error {
|
||||
@@ -21,7 +21,7 @@ typedef struct Error {
|
||||
List call_stack;
|
||||
} Error;
|
||||
|
||||
Error* Error_create(const char* msg, bool is_msg_on_heap, ErrorCallPos);
|
||||
Error* Error_create(const char* msg, bool is_msg_on_heap, ErrorCallPos p);
|
||||
void Error_destroy(Error* e);
|
||||
void Error_addCallPos(Error* e, ErrorCallPos p);
|
||||
str Error_toStr(Error* e);
|
||||
@@ -56,6 +56,7 @@ typedef struct Result_ {
|
||||
#define try_fatal(VAR, RSLT_CALL, DEFER_CODE) \
|
||||
Result_ VAR = RSLT_CALL;\
|
||||
if(VAR.error){\
|
||||
Error_addCallPos(VAR.error, ErrorCallPos_here());\
|
||||
DEFER_CODE;\
|
||||
Error_printAndExit(VAR.error);\
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@ void StringBuilder_destroy(StringBuilder* b);
|
||||
/// @param count set to -1 to clear StringBuilder
|
||||
void StringBuilder_removeFromEnd(StringBuilder* b, u32 count);
|
||||
void StringBuilder_append_char(StringBuilder* b, char c);
|
||||
void StringBuilder_append_cstr(StringBuilder* b, char* s);
|
||||
void StringBuilder_append_cstr(StringBuilder* b, cstr s);
|
||||
void StringBuilder_append_str(StringBuilder* b, str s);
|
||||
void StringBuilder_append_i64(StringBuilder* b, i64 a);
|
||||
void StringBuilder_append_u64(StringBuilder* b, u64 a);
|
||||
|
||||
Reference in New Issue
Block a user