improved error handling a bit

This commit is contained in:
hyunghwan.chung 2017-12-27 10:32:57 +00:00
parent 3c6b73b2b5
commit 9f27e27d25
5 changed files with 180 additions and 165 deletions

View File

@ -227,7 +227,7 @@ static moo_oop_association_t lookup (moo_t* moo, moo_oop_dic_t dic, const moo_oo
} }
/* when value is MOO_NULL, perform no insertion */ /* when value is MOO_NULL, perform no insertion */
moo_seterrnum (moo, MOO_ENOENT); moo_seterrbfmt (moo, MOO_ENOENT, "unable to find %.*js in a dictionary", name->len, name->ptr);
return MOO_NULL; return MOO_NULL;
} }

File diff suppressed because it is too large Load Diff

View File

@ -2022,11 +2022,12 @@ static int handle_logopt (moo_t* moo, const moo_bch_t* str)
cm = moo_findbcharinbcstr(flt, ','); cm = moo_findbcharinbcstr(flt, ',');
if (cm) *cm = '\0'; if (cm) *cm = '\0';
if (moo_compbcstr (flt, "app") == 0) xtn->logmask |= MOO_LOG_APP; if (moo_compbcstr(flt, "app") == 0) xtn->logmask |= MOO_LOG_APP;
else if (moo_compbcstr (flt, "mnemonic") == 0) xtn->logmask |= MOO_LOG_MNEMONIC; else if (moo_compbcstr(flt, "vm") == 0) xtn->logmask |= MOO_LOG_VM;
else if (moo_compbcstr (flt, "gc") == 0) xtn->logmask |= MOO_LOG_GC; else if (moo_compbcstr(flt, "mnemonic") == 0) xtn->logmask |= MOO_LOG_MNEMONIC;
else if (moo_compbcstr (flt, "ic") == 0) xtn->logmask |= MOO_LOG_IC; else if (moo_compbcstr(flt, "gc") == 0) xtn->logmask |= MOO_LOG_GC;
else if (moo_compbcstr (flt, "primitive") == 0) xtn->logmask |= MOO_LOG_PRIMITIVE; else if (moo_compbcstr(flt, "ic") == 0) xtn->logmask |= MOO_LOG_IC;
else if (moo_compbcstr(flt, "primitive") == 0) xtn->logmask |= MOO_LOG_PRIMITIVE;
} }
while (cm); while (cm);
@ -2318,7 +2319,7 @@ int main (int argc, char* argv[])
mthname.len = 4; mthname.len = 4;
if (moo_invoke (moo, &objname, &mthname) <= -1) if (moo_invoke (moo, &objname, &mthname) <= -1)
{ {
moo_logbfmt (moo, MOO_LOG_ERROR, "ERROR: cannot execute code - [%d] %js\n", moo_geterrnum(moo), moo_geterrstr(moo)); moo_logbfmt (moo, MOO_LOG_ERROR, "ERROR: cannot execute code - [%d] %js\n", moo_geterrnum(moo), moo_geterrmsg(moo));
xret = -1; xret = -1;
} }

View File

@ -1164,7 +1164,7 @@ moo_oop_t moo_divints (
moo_t* moo, moo_t* moo,
moo_oop_t x, moo_oop_t x,
moo_oop_t y, moo_oop_t y,
int modulo, int modulo,
moo_oop_t* rem moo_oop_t* rem
); );
@ -1248,7 +1248,7 @@ moo_oop_t moo_strtoint (
moo_t* moo, moo_t* moo,
const moo_ooch_t* str, const moo_ooch_t* str,
moo_oow_t len, moo_oow_t len,
int radix int radix
); );
moo_oop_t moo_inttostr ( moo_oop_t moo_inttostr (

View File

@ -1407,25 +1407,25 @@ struct moo_t
enum moo_log_mask_t enum moo_log_mask_t
{ {
MOO_LOG_DEBUG = (1 << 0), MOO_LOG_DEBUG = (1 << 0),
MOO_LOG_INFO = (1 << 1), MOO_LOG_INFO = (1 << 1),
MOO_LOG_WARN = (1 << 2), MOO_LOG_WARN = (1 << 2),
MOO_LOG_ERROR = (1 << 3), MOO_LOG_ERROR = (1 << 3),
MOO_LOG_FATAL = (1 << 4), MOO_LOG_FATAL = (1 << 4),
MOO_LOG_MNEMONIC = (1 << 7), /* bytecode mnemonic */
MOO_LOG_GC = (1 << 8),
MOO_LOG_IC = (1 << 9), /* instruction cycle, fetch-decode-execute */
MOO_LOG_PRIMITIVE = (1 << 10),
MOO_LOG_APP = (1 << 11), /* moo applications, set by moo logging primitive */
MOO_LOG_VM = (1 << 6),
MOO_LOG_MNEMONIC = (1 << 7), /* bytecode mnemonic */
MOO_LOG_GC = (1 << 8),
MOO_LOG_IC = (1 << 9), /* instruction cycle, fetch-decode-execute */
MOO_LOG_PRIMITIVE = (1 << 10),
MOO_LOG_APP = (1 << 11), /* moo applications, set by moo logging primitive */
MOO_LOG_ALL_LEVELS = (MOO_LOG_DEBUG | MOO_LOG_INFO | MOO_LOG_WARN | MOO_LOG_ERROR | MOO_LOG_FATAL), MOO_LOG_ALL_LEVELS = (MOO_LOG_DEBUG | MOO_LOG_INFO | MOO_LOG_WARN | MOO_LOG_ERROR | MOO_LOG_FATAL),
MOO_LOG_ALL_TYPES = (MOO_LOG_MNEMONIC | MOO_LOG_GC | MOO_LOG_IC | MOO_LOG_PRIMITIVE | MOO_LOG_APP), MOO_LOG_ALL_TYPES = (MOO_LOG_VM | MOO_LOG_MNEMONIC | MOO_LOG_GC | MOO_LOG_IC | MOO_LOG_PRIMITIVE | MOO_LOG_APP),
MOO_LOG_STDOUT = (1 << 14), /* write log messages to stdout without timestamp. MOO_LOG_STDOUT wins over MOO_LOG_STDERR. */ MOO_LOG_STDOUT = (1 << 14), /* write log messages to stdout without timestamp. MOO_LOG_STDOUT wins over MOO_LOG_STDERR. */
MOO_LOG_STDERR = (1 << 15), /* write log messages to stderr without timestamp. */ MOO_LOG_STDERR = (1 << 15), /* write log messages to stderr without timestamp. */
}; };
typedef enum moo_log_mask_t moo_log_mask_t; typedef enum moo_log_mask_t moo_log_mask_t;