changed error message handling a little bit

This commit is contained in:
hyunghwan.chung 2018-02-12 10:19:33 +00:00
parent 48bee5a2c8
commit 374a2242d1

View File

@ -565,22 +565,13 @@ moo_mod_data_t* moo_openmod (moo_t* moo, const moo_ooch_t* name, moo_oow_t namel
return MOO_NULL;
}
moo_seterrnum (moo, MOO_ENOERR);
/* attempt to get moo_mod_xxx where xxx is the module name*/
load = moo->vmprim.dl_getsym (moo, md.handle, buf);
if (!load)
{
if (moo_geterrnum(moo) == MOO_ENOERR)
{
moo_seterrbfmt (moo, MOO_ENOENT, "unable to get module symbol [%js] in [%.*js]", buf,namelen, name);
}
else
{
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, oldmsg);
}
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, oldmsg);
MOO_DEBUG3 (moo, "Cannot get a module symbol [%js] in [%.*js]\n", buf, namelen, name);
moo->vmprim.dl_close (moo, md.handle);
return MOO_NULL;
}
@ -599,19 +590,10 @@ moo_mod_data_t* moo_openmod (moo_t* moo, const moo_ooch_t* name, moo_oow_t namel
mdp = (moo_mod_data_t*)MOO_RBT_VPTR(pair);
MOO_ASSERT (moo, MOO_SIZEOF(mdp->mod.hints) == MOO_SIZEOF(int));
mdp->mod.hints = hints;
moo_seterrnum (moo, MOO_ENOERR);
if (load (moo, &mdp->mod) <= -1)
{
if (moo_geterrnum(moo) == MOO_ENOERR)
{
moo_seterrbfmt (moo, MOO_EGENERIC, "module initializer [%js] returned failure in [%.*js]", buf, namelen, name);
}
else
{
const moo_ooch_t* oldmsg = moo_backuperrmsg (moo);
moo_seterrbfmt (moo, moo_geterrnum(moo), "module initializer [%js] returned failure in [%.*js] - %js", buf, namelen, name, oldmsg);
}
const moo_ooch_t* oldmsg = moo_backuperrmsg (moo);
moo_seterrbfmt (moo, moo_geterrnum(moo), "module initializer [%js] returned failure in [%.*js] - %js", buf, namelen, name, oldmsg);
MOO_DEBUG3 (moo, "Module function [%js] returned failure in [%.*js]\n", buf, namelen, name);
moo_rbt_delete (&moo->modtab, name, namelen);
moo->vmprim.dl_close (moo, mdp->handle);