Skip to content

Instantly share code, notes, and snippets.

@EngineerSmith
Created November 20, 2025 11:45
Show Gist options
  • Select an option

  • Save EngineerSmith/496c283f459b97aafa5cbb6485e57c4c to your computer and use it in GitHub Desktop.

Select an option

Save EngineerSmith/496c283f459b97aafa5cbb6485e57c4c to your computer and use it in GitHub Desktop.
local patterns = {
boot = "%[love \"boot%.lua\"%]:%d+:",
callbacks = "%[love \"callbacks%.lua\"%]:%d+:",
}
local match = function(line, pattern)
return type(line) == "string" and line:find(pattern)
end
local filterPatterns = {
{ -- Remove the `logger.error` instance call
pattern = "/logger/init%.lua:%d+: in function 'error'",
condition = function(lines, i)
return love.mintmousse._insideError and match(lines[i-1], "%[C%]: in function 'error'")
end,
counts = 1,
},
{ -- Remove the `love.errorhandler` call
pattern = "%.lua:%d+: in function 'handler'",
condition = function(lines, i)
local insideIssue = love.mintmousse._insideFatal or love.mintmousse._insideError
return insideIssue and match(lines[i+1], patterns.boot)
end,
counts = 1,
},
{ -- Remove love internal `xpcall` call; works by searching the stack above for "boot.lua"
pattern = "%[C%]: in function 'xpcall'",
condition = function(lines, i)
return match(lines[i+1], patterns.boot) or match(lines[i-1], patterns.callbacks)
end,
counts = -1,
},
{ -- Remove love internal `require` call; works by searching the stack above for "boot.lua"
pattern = "%[C%]: in function 'require'",
condition = function(lines, i)
return match(lines[i+1], patterns.boot)
end,
counts = -1,
},
{ pattern = patterns.boot, counts = -1 }, -- Remove all love internal boot calls
{ pattern = patterns.callbacks, counts = -1 }, -- Remove all love internal callbacks calls
}
table.sort(filterPatterns, function(a, b)
if a.counts == -1 and b.counts == -1 then return false end
if a.counts == -1 then return true end
if b.counts == -1 then return false end
return a.counts > b.counts
end)
-- Cleans up a traceback string by removing lines matching specific filters to make the issue much more visible.
love.mintmousse._cleanUpTraceback = function(traceback)
if traceback:find("\n$") then
traceback = traceback .. "\n"
end
local lines = { }
for line in (traceback):gmatch("([^\n]+)\n") do
table.insert(lines, line)
end
local toRemove = { }
for _, rule in ipairs(filterPatterns) do
local count = rule.counts
for i, line in ipairs(lines) do
if toRemove[i] then
goto continue
end
if line:find(rule.pattern) then
local conditionMet = true
if rule.condition then
conditionMet = rule.condition(lines, i)
end
if conditionMet then
toRemove[i] = true
if count ~= -1 then
count = count - 1
if count == 0 then break end
end
end
end
::continue::
end
end
local cleanLines = { }
for i, line in ipairs(lines) do
if not toRemove[i] then
table.insert(cleanLines, line)
end
end
return table.concat(cleanLines, "\n") .. "\n"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment