added moo_backuperrmsg()

This commit is contained in:
hyunghwan.chung 2018-01-19 17:44:07 +00:00
parent d54552aff8
commit e33ea4321e
4 changed files with 19 additions and 9 deletions

View File

@ -7728,9 +7728,9 @@ static int __compile_class_definition (moo_t* moo, int extend)
* this extra module name, i'm free from GC headache */ * this extra module name, i'm free from GC headache */
if (moo_importmod (moo, moo->c->cls.self_oop, moo->c->cls.modname.ptr, moo->c->cls.modname.len) <= -1) if (moo_importmod (moo, moo->c->cls.self_oop, moo->c->cls.modname.ptr, moo->c->cls.modname.len) <= -1)
{ {
moo_copyoocstr (moo->errmsg.tmpbuf.ooch, MOO_COUNTOF(moo->errmsg.tmpbuf.ooch), moo->errmsg.buf); const moo_ooch_t* oldmsg = moo_backuperrmsg(moo);
set_syntax_errbfmt (moo, MOO_SYNERR_MODIMPFAIL, &moo->c->cls.modname_loc, &moo->c->cls.modname, set_syntax_errbfmt (moo, MOO_SYNERR_MODIMPFAIL, &moo->c->cls.modname_loc, &moo->c->cls.modname,
"unable to import %.*js - %js", moo->c->cls.modname.len, moo->c->cls.modname.ptr, moo->errmsg.tmpbuf.ooch); "unable to import %.*js - %js", moo->c->cls.modname.len, moo->c->cls.modname.ptr, oldmsg);
return -1; return -1;
} }
} }

View File

@ -306,6 +306,12 @@ const moo_ooch_t* moo_geterrmsg (moo_t* moo)
return moo->errmsg.buf; return moo->errmsg.buf;
} }
const moo_ooch_t* moo_backuperrmsg (moo_t* moo)
{
moo_copyoocstr (moo->errmsg.tmpbuf.ooch, MOO_COUNTOF(moo->errmsg.tmpbuf.ooch), moo->errmsg.buf);
return moo->errmsg.tmpbuf.ooch;
}
void moo_seterrwithsyserr (moo_t* moo, int syserr) void moo_seterrwithsyserr (moo_t* moo, int syserr)
{ {
if (moo->vmprim.syserrstrb) if (moo->vmprim.syserrstrb)

View File

@ -1140,8 +1140,8 @@ static int add_to_sem_io (moo_t* moo, moo_oop_semaphore_t sem, moo_ooi_t io_hand
tmp = moo_reallocmem (moo, moo->sem_io_map, MOO_SIZEOF(*tmp) * new_capa); tmp = moo_reallocmem (moo, moo->sem_io_map, MOO_SIZEOF(*tmp) * new_capa);
if (!tmp) if (!tmp)
{ {
moo_copyoocstr (moo->errmsg.tmpbuf.ooch, MOO_COUNTOF(moo->errmsg.tmpbuf.ooch), moo->errmsg.buf); const moo_ooch_t* oldmsg = moo_backuperrmsg(moo);
moo_seterrbfmt (moo, moo->errnum, "handle %zd out of supported range - %js", moo->errmsg.tmpbuf.ooch); moo_seterrbfmt (moo, moo->errnum, "handle %zd out of supported range - %js", oldmsg);
return -1; return -1;
} }
@ -2555,8 +2555,8 @@ static moo_pfrc_t __system_add_io_semaphore (moo_t* moo, moo_ooi_t nargs, moo_se
if (add_to_sem_io(moo, sem, MOO_OOP_TO_SMOOI(fd), io_type) <= -1) if (add_to_sem_io(moo, sem, MOO_OOP_TO_SMOOI(fd), io_type) <= -1)
{ {
moo_copyoocstr (moo->errmsg.tmpbuf.ooch, MOO_COUNTOF(moo->errmsg.tmpbuf.ooch), moo->errmsg.buf); const moo_ooch_t* oldmsg = moo_backuperrmsg(moo);
moo_seterrbfmt (moo, moo->errnum, "cannot add the handle %zd to the multiplexer - %js", MOO_OOP_TO_SMOOI(fd), moo->errmsg.tmpbuf.ooch); moo_seterrbfmt (moo, moo->errnum, "cannot add the handle %zd to the multiplexer - %js", MOO_OOP_TO_SMOOI(fd), oldmsg);
return MOO_PF_FAILURE; return MOO_PF_FAILURE;
} }
@ -2615,8 +2615,8 @@ static moo_pfrc_t pf_system_remove_semaphore (moo_t* moo, moo_ooi_t nargs)
if (delete_from_sem_io (moo, sem) <= -1) if (delete_from_sem_io (moo, sem) <= -1)
{ {
moo_copyoocstr (moo->errmsg.tmpbuf.ooch, MOO_COUNTOF(moo->errmsg.tmpbuf.ooch), moo->errmsg.buf); const moo_ooch_t* oldmsg = moo_backuperrmsg(moo);
moo_seterrbfmt (moo, moo->errnum, "cannot delete the handle %zd from the multiplexer - %js", MOO_OOP_TO_SMOOI(sem->io_handle), moo->errmsg.tmpbuf.ooch); moo_seterrbfmt (moo, moo->errnum, "cannot delete the handle %zd from the multiplexer - %js", MOO_OOP_TO_SMOOI(sem->io_handle), oldmsg);
return MOO_PF_FAILURE; return MOO_PF_FAILURE;
} }

View File

@ -1670,11 +1670,15 @@ MOO_EXPORT void moo_seterrwithsyserr (
int syserr int syserr
); );
MOO_EXPORT const moo_ooch_t* moo_geterrstr (
moo_t* moo
);
MOO_EXPORT const moo_ooch_t* moo_geterrmsg ( MOO_EXPORT const moo_ooch_t* moo_geterrmsg (
moo_t* moo moo_t* moo
); );
MOO_EXPORT const moo_ooch_t* moo_geterrstr ( MOO_EXPORT const moo_ooch_t* moo_backuperrmsg (
moo_t* moo moo_t* moo
); );