added hcl_seterrbfmtloc() and hcl_seterrufmtloc()
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
added the errloc field to hcl_t to capture the exception location
This commit is contained in:
27
lib/err.c
27
lib/err.c
@ -286,6 +286,12 @@ void hcl_seterrnum (hcl_t* hcl, hcl_errnum_t errnum)
|
||||
if (hcl->shuterr) return;
|
||||
hcl->errnum = errnum;
|
||||
hcl->errmsg.len = 0;
|
||||
HCL_MEMSET (&hcl->errloc, 0, HCL_SIZEOF(hcl->errloc));
|
||||
}
|
||||
|
||||
void hcl_geterrloc (hcl_t* hcl, hcl_loc_t* loc)
|
||||
{
|
||||
if (loc) *loc = hcl->errloc;
|
||||
}
|
||||
|
||||
void hcl_seterrbmsg (hcl_t* hcl, hcl_errnum_t errnum, const hcl_bch_t* errmsg)
|
||||
@ -293,7 +299,6 @@ void hcl_seterrbmsg (hcl_t* hcl, hcl_errnum_t errnum, const hcl_bch_t* errmsg)
|
||||
hcl_seterrbfmt(hcl, errnum, "%hs", errmsg);
|
||||
}
|
||||
|
||||
|
||||
void hcl_seterrumsg (hcl_t* hcl, hcl_errnum_t errnum, const hcl_uch_t* errmsg)
|
||||
{
|
||||
hcl_seterrbfmt(hcl, errnum, "%ls", errmsg);
|
||||
@ -363,6 +368,7 @@ void hcl_seterrbfmt (hcl_t* hcl, hcl_errnum_t errnum, const hcl_bch_t* fmt, ...)
|
||||
va_end (ap);
|
||||
|
||||
hcl->errnum = errnum;
|
||||
HCL_MEMSET (&hcl->errloc, 0, HCL_SIZEOF(hcl->errloc));
|
||||
}
|
||||
|
||||
void hcl_seterrufmt (hcl_t* hcl, hcl_errnum_t errnum, const hcl_uch_t* fmt, ...)
|
||||
@ -384,6 +390,7 @@ void hcl_seterrufmt (hcl_t* hcl, hcl_errnum_t errnum, const hcl_uch_t* fmt, ...)
|
||||
va_end (ap);
|
||||
|
||||
hcl->errnum = errnum;
|
||||
HCL_MEMSET (&hcl->errloc, 0, HCL_SIZEOF(hcl->errloc));
|
||||
}
|
||||
|
||||
|
||||
@ -403,6 +410,7 @@ void hcl_seterrbfmtv (hcl_t* hcl, hcl_errnum_t errnum, const hcl_bch_t* fmt, va_
|
||||
|
||||
hcl_bfmt_outv (&fo, fmt, ap);
|
||||
hcl->errnum = errnum;
|
||||
HCL_MEMSET (&hcl->errloc, 0, HCL_SIZEOF(hcl->errloc));
|
||||
}
|
||||
|
||||
void hcl_seterrufmtv (hcl_t* hcl, hcl_errnum_t errnum, const hcl_uch_t* fmt, va_list ap)
|
||||
@ -421,9 +429,26 @@ void hcl_seterrufmtv (hcl_t* hcl, hcl_errnum_t errnum, const hcl_uch_t* fmt, va_
|
||||
|
||||
hcl_ufmt_outv (&fo, fmt, ap);
|
||||
hcl->errnum = errnum;
|
||||
HCL_MEMSET (&hcl->errloc, 0, HCL_SIZEOF(hcl->errloc));
|
||||
}
|
||||
|
||||
void hcl_seterrbfmtloc (hcl_t* hcl, hcl_errnum_t errnum, const hcl_loc_t* loc, const hcl_bch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
hcl_seterrbfmtv (hcl, errnum, fmt, ap);
|
||||
va_end (ap);
|
||||
hcl->errloc = *loc;
|
||||
}
|
||||
|
||||
void hcl_seterrufmtloc (hcl_t* hcl, hcl_errnum_t errnum, const hcl_loc_t* loc, const hcl_uch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, fmt);
|
||||
hcl_seterrufmtv (hcl, errnum, fmt, ap);
|
||||
va_end (ap);
|
||||
hcl->errloc = *loc;
|
||||
}
|
||||
|
||||
void hcl_seterrwithsyserr (hcl_t* hcl, int syserr_type, int syserr_code)
|
||||
{
|
||||
|
13
lib/exec.c
13
lib/exec.c
@ -2310,9 +2310,15 @@ static HCL_INLINE int do_throw (hcl_t* hcl, hcl_oop_t val, hcl_ooi_t ip)
|
||||
if (hcl->active_function->dbgi != hcl->_nil)
|
||||
{
|
||||
hcl_dbgi_t* dbgi;
|
||||
hcl_loc_t loc;
|
||||
|
||||
dbgi = (hcl_dbgi_t*)HCL_OBJ_GET_BYTE_SLOT(hcl->active_function->dbgi);
|
||||
HCL_LOG3 (hcl, HCL_LOG_IC | HCL_LOG_WARN, "Warning - exception not handled %js:%zu- %O", (dbgi[ip].fname? dbgi[ip].fname: oocstr_dash), dbgi[ip].sline, val);
|
||||
hcl_seterrbfmt (hcl, HCL_EEXCEPT, "exception not handled in %js:%zu - %O", (dbgi[ip].fname? dbgi[ip].fname: oocstr_dash), dbgi[ip].sline, val);
|
||||
HCL_MEMSET (&loc, 0, HCL_SIZEOF(loc));
|
||||
loc.file = dbgi[ip].fname;
|
||||
loc.line = dbgi[ip].sline;
|
||||
hcl_seterrbfmtloc (hcl, HCL_EEXCEPT, &loc, "exception not handled - %O", val);
|
||||
/* column number is not available */
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2360,14 +2366,17 @@ static void supplement_errmsg (hcl_t* hcl, hcl_ooi_t ip)
|
||||
if (hcl->active_function->dbgi != hcl->_nil)
|
||||
{
|
||||
hcl_dbgi_t* dbgi;
|
||||
hcl_loc_t orgloc = hcl->errloc;
|
||||
const hcl_ooch_t* orgmsg = hcl_backuperrmsg(hcl);
|
||||
hcl_errnum_t orgnum = HCL_ERRNUM(hcl);
|
||||
|
||||
HCL_ASSERT (hcl, HCL_IS_BYTEARRAY(hcl, hcl->active_function->dbgi));
|
||||
dbgi = (hcl_dbgi_t*)HCL_OBJ_GET_BYTE_SLOT(hcl->active_function->dbgi);
|
||||
|
||||
hcl_seterrbfmt (hcl, orgnum, "%js (%js:%zu)", orgmsg,
|
||||
hcl_seterrbfmtloc (hcl, orgnum, &orgloc, "%js (%js:%zu)", orgmsg,
|
||||
(dbgi[ip].fname? dbgi[ip].fname: oocstr_dash), dbgi[ip].sline);
|
||||
|
||||
/* no column info available */
|
||||
}
|
||||
}
|
||||
|
||||
|
25
lib/hcl.h
25
lib/hcl.h
@ -1513,7 +1513,6 @@ struct hcl_synerr_t
|
||||
} tgt;
|
||||
};
|
||||
|
||||
|
||||
typedef struct hcl_dbgi_t hcl_dbgi_t;
|
||||
struct hcl_dbgi_t
|
||||
{
|
||||
@ -1590,6 +1589,7 @@ struct hcl_t
|
||||
hcl_oow_t len;
|
||||
|
||||
} errmsg;
|
||||
hcl_loc_t errloc;
|
||||
int shuterr;
|
||||
|
||||
struct
|
||||
@ -2164,6 +2164,11 @@ HCL_EXPORT void hcl_seterrnum (
|
||||
hcl_errnum_t errnum
|
||||
);
|
||||
|
||||
HCL_EXPORT void hcl_geterrloc (
|
||||
hcl_t* hcl,
|
||||
hcl_loc_t* loc
|
||||
);
|
||||
|
||||
HCL_EXPORT void hcl_seterrbmsg (
|
||||
hcl_t* hcl,
|
||||
hcl_errnum_t errnum,
|
||||
@ -2212,6 +2217,22 @@ HCL_EXPORT void hcl_seterrufmt (
|
||||
...
|
||||
);
|
||||
|
||||
HCL_EXPORT void hcl_seterrbfmtloc (
|
||||
hcl_t* hcl,
|
||||
hcl_errnum_t errnum,
|
||||
const hcl_loc_t* loc,
|
||||
const hcl_bch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
HCL_EXPORT void hcl_seterrufmtloc (
|
||||
hcl_t* hcl,
|
||||
hcl_errnum_t errnum,
|
||||
const hcl_loc_t* loc,
|
||||
const hcl_uch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
HCL_EXPORT void hcl_seterrbfmtv (
|
||||
hcl_t* hcl,
|
||||
hcl_errnum_t errnum,
|
||||
@ -2226,6 +2247,7 @@ HCL_EXPORT void hcl_seterrufmtv (
|
||||
va_list ap
|
||||
);
|
||||
|
||||
|
||||
HCL_EXPORT const hcl_ooch_t* hcl_geterrstr (
|
||||
hcl_t* hcl
|
||||
);
|
||||
@ -2536,7 +2558,6 @@ static HCL_INLINE hcl_ooi_t hcl_getip (hcl_t* hcl) { return hcl->ip; }
|
||||
# define hcl_getip(hcl) ((hcl)->ip)
|
||||
#endif
|
||||
|
||||
|
||||
/* =========================================================================
|
||||
* SYNTAX ERROR HANDLING
|
||||
* ========================================================================= */
|
||||
|
Reference in New Issue
Block a user