REM Return a mal value corresponding to the most-recently thrown exception.
DEF FNwrap_exception
+ REM There are three cases to handle. When the error was generated
+ REM by 'throw', we should return the value that 'throw' stashed in
+ REM MAL_ERR%. When the error was generated by mal, we should just
+ REM return the error message. When the error was generated by BASIC
+ REM or the OS, we should wrap the message and the error number in
+ REM a hash-map.
IF ERR = &40E80900 THEN =MAL_ERR% : REM Error generated by 'throw'
-=FNalloc_string(REPORT$) : REM OS error or error generated by mal
+ IF (ERR AND &FFFFFF00) = &40E80900 THEN =FNalloc_string(REPORT$)
+ LOCAL e%
+ e% = FNhashmap_set(FNempty_hashmap, "err", FNalloc_int(ERR))
+=FNhashmap_set(e%, "message", FNalloc_string(REPORT$))
DEF FNcatch(ast%, env%, err%)
LOCAL binds%, exprs%
REM Return a mal value corresponding to the most-recently thrown exception.
DEF FNwrap_exception
+ REM There are three cases to handle. When the error was generated
+ REM by 'throw', we should return the value that 'throw' stashed in
+ REM MAL_ERR%. When the error was generated by mal, we should just
+ REM return the error message. When the error was generated by BASIC
+ REM or the OS, we should wrap the message and the error number in
+ REM a hash-map.
IF ERR = &40E80900 THEN =MAL_ERR% : REM Error generated by 'throw'
-=FNalloc_string(REPORT$) : REM OS error or error generated by mal
+ IF (ERR AND &FFFFFF00) = &40E80900 THEN =FNalloc_string(REPORT$)
+ LOCAL e%
+ e% = FNhashmap_set(FNempty_hashmap, "err", FNalloc_int(ERR))
+=FNhashmap_set(e%, "message", FNalloc_string(REPORT$))
DEF FNcatch(ast%, env%, err%)
LOCAL binds%, exprs%