You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, this does not work. When throwing an error in a .yue file, the call to yue.require() will not fail and just return nothing. The error handler defined here will not be called, either. Furthermore, yue.require() always prints a traceback with yue.traceback().
The screenshot shows a file called temp.yue that contains the following code:
const f =()->error("Test message")
f()
It is being executed with LuaJIT, with the following code:
Test message
Stack Traceback
===============
(1) '=(yuescript)':172
(2) global C function 'pcall'
(3) '=stdin':1
(4) C function 'function: 0x7e8c2865c588'
true nil
The text was updated successfully, but these errors were encountered:
_G.yue=require("yue")
s, r=xpcall(
(() ->require("nonexistent_file")),
((err)->print("THIS IS NOT MISSING IN OUTPUT"))
)
s, r=xpcall(
(()->yue.require("nonexistent_file")),
((err)->print("THIS IS MISSING IN OUTPUT"))
)
The yue.require() function was unintentionally swallowing errors, which is inconsistent with Lua's standard require() behavior. To align with Lua's conventions, I've decided to remove this shortcut API and instead provide an example for users to handle module loading properly:
The YueScript documentation says to use
yue.require()
to perform custom error handling:However, this does not work. When throwing an error in a
.yue
file, the call toyue.require()
will not fail and just return nothing. The error handler defined here will not be called, either. Furthermore,yue.require()
always prints a traceback withyue.traceback()
.The screenshot shows a file called
temp.yue
that contains the following code:It is being executed with LuaJIT, with the following code:
The output is:
The text was updated successfully, but these errors were encountered: