Help with warn & errors in modules

How would I make a warn/error in a module reference the script that the module was required in?

Any help much appreicated!
Thanks in advance.

debug.info might be a useful function, it can be used to travel up the stack trace and return some useful information about it.

print(debug.info(2, "sln") --> workspace.Script 1 <nil>

To get the full path as a string, of a script, try using the s argument. This will also return C funcs which dont have a defined source, so make sure to handle that.

You can also change the source of an error with its second argument, though this wont affect the stack trace.

error("error higher up the stack trace", 2)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.