small changes
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#include "errors.h"
|
||||
#include "cptr.h"
|
||||
|
||||
char* errname(err_t err){
|
||||
char* errname(ErrorId err){
|
||||
switch(err){
|
||||
case SUCCESS: return "SUCCESS";
|
||||
case ERR_MAXLENGTH: return "ERR_MAXLENGTH";
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "errors.hpp"
|
||||
|
||||
void throwcpp(err_t eid){
|
||||
throwcpp(errname(eid));
|
||||
void throwcpp_id(ErrorId eid){
|
||||
throwcpp_msg(errname(eid));
|
||||
}
|
||||
|
||||
void throwcpp(char* emsg){
|
||||
void throwcpp_msg(char* emsg){
|
||||
__EXIT(emsg);
|
||||
}
|
||||
@@ -7,12 +7,12 @@ extern "C" {
|
||||
#include "std.h"
|
||||
#include "types.h"
|
||||
|
||||
typedef enum err_t {
|
||||
typedef enum ErrorId {
|
||||
SUCCESS, // not an error
|
||||
ERR_MAXLENGTH, ERR_WRONGTYPE, ERR_WRONGINDEX, ERR_NOTIMPLEMENTED, ERR_NULLPTR, ERR_ENDOFSTR
|
||||
} err_t;
|
||||
} ErrorId;
|
||||
|
||||
char* errname(err_t err);
|
||||
char* errname(ErrorId err);
|
||||
|
||||
char* __genErrMsg(const char* errmsg, const char* srcfile, int line, const char* funcname);
|
||||
char* __extendErrMsg(const char* errmsg, const char* srcfile, int line, const char* funcname);
|
||||
@@ -21,8 +21,10 @@ typedef struct Maybe{
|
||||
Unitype value;
|
||||
char* errmsg;
|
||||
} Maybe;
|
||||
|
||||
// return it if func doesn't return anything
|
||||
static const Maybe MaybeNull={.value.type=Null, .value.VoidPtr=NULL,.errmsg=NULL};
|
||||
// .value .errmsg
|
||||
static const Maybe MaybeNull={UniNull, NULL};
|
||||
|
||||
void Maybe_free(Maybe e);
|
||||
void printMaybe(Maybe e);
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
#ifdef __cplusplus
|
||||
#include "errors.h"
|
||||
|
||||
void throwcpp(err_t eid);
|
||||
void throwcpp(char* emsg);
|
||||
void throwcpp_id(ErrorId eid);
|
||||
void throwcpp_msg(char* emsg);
|
||||
#endif
|
||||
Reference in New Issue
Block a user