-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbugcatcher.lua
81 lines (63 loc) · 2.77 KB
/
bugcatcher.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
--- Name...........: BugCatcher
-- Description....: Adds LUI Version and Revision numbers to lua errors relating to LUI
-- These AddOns replace the seterrorhandler function, bail out if any of them are enabled
if IsAddOnLoaded("!BugGrabber") or IsAddOnLoaded("!Swatter") or IsAddOnLoaded("!ImprovedErrorFrame") then return end
local addonname, LUI = ...
----------------------------------------------------------------------
-- Localized API
----------------------------------------------------------------------
local _G = _G
local format, strfind, gsub = string.format, string.find, string.gsub
----------------------------------------------------------------------
-- Initialize BugCatcher
----------------------------------------------------------------------
local BugCatcher = LibStub("AceHook-3.0"):Embed( {} )
local L = LUI.L
----------------------------------------------------------------------
-- Local Variables
----------------------------------------------------------------------
local text
do -- Create format string
local version, revision = GetAddOnMetadata(addonname, "Version"), GetAddOnMetadata(addonname, "X-Curse-Packaged-Version") or "Working Copy"
if version == revision then
text = format("LUI %s", version)
else
text = format("LUI %s (%s)", version, revision)
end
end
----------------------------------------------------------------------
-- Local Functions
----------------------------------------------------------------------
--- formatError(message)
-- Notes.....: Adds Version and Revision numbers to error strings relating to LUI
-- Parameters:
-- (string) message: Message string to have Version and Revision number added to
local function formatError(message)
if message and strfind(message, "LUI\\") then
-- Strip out unneeded folder data
message = gsub(message, "Interface\\", "")
message = gsub(message, "AddOns\\", "")
message = gsub(message, "%.%.%.[^\\]+", "")
message = gsub(message, "^[\\]?LUI", text)
end
return message
end
----------------------------------------------------------------------
-- Hook Functions
----------------------------------------------------------------------
function BugCatcher:ScriptErrorsFrame_OnError(message, ...)
DEBUGLOCALS_LEVEL = 6
self.hooks.ScriptErrorsFrame_OnError(formatError(message), ...)
end
LoadAddOn("Blizzard_DebugTools")
BugCatcher:RawHook("ScriptErrorsFrame_OnError", true)
-- Register slash command for testing (/luierror)
--[===[@debug@
SLASH_LUIERROR1 = "/luierror"
SlashCmdList.LUIERROR = function()
-- Hide the ChatEditBox, the error will stop the function that normally does this from running
ChatEdit_OnEscapePressed(ChatEdit_GetActiveWindow())
-- Send a test error,
error("LUI Error Test")
end
--@end-debug@]===]