2013/Libraries/Fusion/Logging/parseError.luau

25 lines
479 B
Plaintext

--!strict
--[[
An xpcall() error handler to collect and parse useful information about
errors, such as clean messages and stack traces.
]]
local Types = require "../Types"
local function parseError(err: string): Types.Error
local trace
if debug and debug.traceback then
trace = debug.traceback(nil, 2)
end
return {
type = "Error",
raw = err,
message = string.gsub(err, "^.+:%d+:%s*", ""),
trace = trace or "Traceback not available",
}
end
return parseError