touched up error message handling

This commit is contained in:
hyunghwan.chung 2018-02-12 16:50:32 +00:00
parent b64fdb0019
commit 88861aa522
2 changed files with 24 additions and 16 deletions

View File

@ -542,8 +542,10 @@ static void* dl_open (moo_t* moo, const moo_ooch_t* name, int flags)
if (!handle) if (!handle)
{ {
moo_bch_t* dash; moo_bch_t* dash;
moo_seterrbfmt (moo, MOO_ESYSERR, "unable to open(ext) DL %js - %hs", name, sys_dl_error()); const moo_bch_t* dl_errstr;
MOO_DEBUG3 (moo, "Failed to open(ext) DL %hs[%js] - %hs\n", &bufptr[len], name, sys_dl_error()); dl_errstr = sys_dl_error();
MOO_DEBUG3 (moo, "Failed to open(ext) DL %hs[%js] - %hs\n", &bufptr[len], name, dl_errstr);
moo_seterrbfmt (moo, MOO_ESYSERR, "unable to open(ext) DL %js - %hs", name, dl_errstr);
dash = moo_rfindbchar(bufptr, moo_countbcstr(bufptr), '-'); dash = moo_rfindbchar(bufptr, moo_countbcstr(bufptr), '-');
if (dash) if (dash)
{ {
@ -580,8 +582,10 @@ static void* dl_open (moo_t* moo, const moo_ooch_t* name, int flags)
handle = sys_dl_open(bufptr); handle = sys_dl_open(bufptr);
if (!handle) if (!handle)
{ {
moo_seterrbfmt (moo, MOO_ESYSERR, "unable to open DL %js - %hs", name, sys_dl_error()); const moo_bch_t* dl_errstr;
MOO_DEBUG2 (moo, "Failed to open DL %hs - %hs\n", bufptr, sys_dl_error()); dl_errstr = sys_dl_error();
MOO_DEBUG2 (moo, "Failed to open DL %hs - %hs\n", bufptr, dl_errstr);
moo_seterrbfmt (moo, MOO_ESYSERR, "unable to open DL %js - %hs", name, dl_errstr);
} }
else MOO_DEBUG2 (moo, "Opened DL %hs handle %p\n", bufptr, handle); else MOO_DEBUG2 (moo, "Opened DL %hs handle %p\n", bufptr, handle);
} }
@ -590,8 +594,10 @@ static void* dl_open (moo_t* moo, const moo_ooch_t* name, int flags)
handle = sys_dl_openext(bufptr); handle = sys_dl_openext(bufptr);
if (!handle) if (!handle)
{ {
moo_seterrbfmt (moo, MOO_ESYSERR, "unable to open(ext) DL %js - %hs", name, sys_dl_error()); const moo_bch_t* dl_errstr;
MOO_DEBUG2 (moo, "Failed to open(ext) DL %hs - %hs\n", bufptr, sys_dl_error()); dl_errstr = sys_dl_error();
MOO_DEBUG2 (moo, "Failed to open(ext) DL %hs - %hs\n", bufptr, dl_errstr);
moo_seterrbfmt (moo, MOO_ESYSERR, "unable to open(ext) DL %js - %hs", name, dl_errstr);
} }
else MOO_DEBUG2 (moo, "Opened(ext) DL %hs handle %p\n", bufptr, handle); else MOO_DEBUG2 (moo, "Opened(ext) DL %hs handle %p\n", bufptr, handle);
} }
@ -679,7 +685,10 @@ static void* dl_getsym (moo_t* moo, void* handle, const moo_ooch_t* name)
sym = sys_dl_getsym(handle, symname); sym = sys_dl_getsym(handle, symname);
if (!sym) if (!sym)
{ {
moo_seterrbfmt (moo, MOO_ENOENT, "unable to get module symbol %hs", symname); const moo_bch_t* dl_errstr;
dl_errstr = sys_dl_error();
MOO_DEBUG3 (moo, "Failed to get module symbol %js from handle %p - %hs\n", name, handle, dl_errstr);
moo_seterrbfmt (moo, MOO_ENOENT, "unable to get module symbol %hs - %hs", symname, dl_errstr);
} }
} }
} }

View File

@ -569,8 +569,7 @@ moo_mod_data_t* moo_openmod (moo_t* moo, const moo_ooch_t* name, moo_oow_t namel
load = moo->vmprim.dl_getsym(moo, md.handle, buf); load = moo->vmprim.dl_getsym(moo, md.handle, buf);
if (!load) if (!load)
{ {
const moo_ooch_t* oldmsg = moo_backuperrmsg (moo); moo_seterrbfmt (moo, moo_geterrnum(moo), "unable to get module symbol [%js] in [%.*js] - %js", buf,namelen, name);
moo_seterrbfmt (moo, moo_geterrnum(moo), "unable to get module symbol [%js] in [%.*js] - %js", buf,namelen, name, oldmsg);
MOO_DEBUG3 (moo, "Cannot get a module symbol [%js] in [%.*js]\n", buf, namelen, name); MOO_DEBUG3 (moo, "Cannot get a module symbol [%js] in [%.*js]\n", buf, namelen, name);
moo->vmprim.dl_close (moo, md.handle); moo->vmprim.dl_close (moo, md.handle);
return MOO_NULL; return MOO_NULL;