Improve error trace reporting

This commit is contained in:
aaron 2023-08-21 21:57:11 +01:00
parent ccb36df365
commit be15f69522
2 changed files with 19 additions and 2 deletions

View file

@ -1,8 +1,25 @@
local function get_path(s)
if string.sub(s, #s - 4, #s) == ".luau" then
s = string.sub(s, 1, #s - 5)
print("test, ", s)
end
return string.split(s, string.match(s, "%w+/") and "/" or ".")
end
local root do
local path = get_path(debug.info(1, "s"))
root = path[#path - 1]
end
local function throw(msg: string) local function throw(msg: string)
local stack = 1 local stack = 1
while debug.info(stack, "s") == debug.info(1, "s") do local path = get_path(debug.info(stack, "s"))
while path[#path] == root or path[#path - 1] == root do
stack += 1 stack += 1
path = get_path(debug.info(stack, "s"))
end end
error(msg, stack) error(msg, stack)

View file

@ -5,7 +5,7 @@
- better error reporting and stack traces in strict mode - better error reporting and stack traces in strict mode
- auto-enable of strict mode depending on compiler optimizaton level - auto-enable of strict mode depending on compiler optimizaton level
- check smoothness of spring at high frequency updates - check smoothness of spring at high frequency updates
- review alternative to nested properties, merge function - aggregate initialization of properties
- implement from solid - implement from solid
- [x] onCleanup > `cleanup()` - [x] onCleanup > `cleanup()`
- [x] Index > `indexes()` - [x] Index > `indexes()`