public
Description: WoW Addon - Lua error manager
Homepage: http://www.tekkub.net/
Clone URL: git://github.com/tekkub/tekerr.git
Click here to lend your support to: tekerr and make a donation at www.pledgie.com !
tekerr / tekErr.lua
100644 106 lines (87 sloc) 3.235 kb
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
local linkstr = "|cffff4040[%s] |Htekerr:%s|h%s|h|r"
local lastName, butt
 
 
local buttfunc = tekErrMinimapButton
tekErrMinimapButton = nil
 
 
local panel = LibStub("tekPanel-Auction").new("tekErrPanel", "tekErr")
local f = CreateFrame("ScrollingMessageFrame", nil, panel)
f:SetPoint("BOTTOMRIGHT", -15, 40)
f:SetMaxLines(250)
f:SetFontObject(GameFontHighlightSmall)
f:SetJustifyH("LEFT")
f:SetFading(false)
f:SetScript("OnShow", function() if butt then butt:Hide() end end)
f:SetScript("OnEvent", function(self, ...) self:AddMessage(string.join(", ", ...), 0.0, 1.0, 1.0) end)
f:RegisterEvent("ADDON_ACTION_FORBIDDEN")
--~ f:RegisterEvent("ADDON_ACTION_BLOCKED") -- We usually don't care about these, as they aren't fatal
TheLowDownRegisterFrame(f)
TheLowDownRegisterFrame = nil
 
 
seterrorhandler(function(msg)
local _, _, stacktrace = string.find(debugstack() or "", "[^\n]+\n(.*)")
f:AddMessage(string.format(linkstr, date("%X"), stacktrace, msg))
if not butt then butt = buttfunc(f); buttfunc = nil end
if not f:IsVisible() then butt:Show() end
end)
 
 
panel:SetScript("OnShow", function(self)
local editbox = CreateFrame("EditBox", nil, panel)
editbox:SetPoint("TOPLEFT", 25, -75)
editbox:SetPoint("BOTTOMRIGHT", panel, "TOPRIGHT", -15, -100)
editbox:SetFontObject(GameFontHighlightSmall)
editbox:SetTextInsets(8,8,8,8)
editbox:SetBackdrop{
bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
edgeSize = 16,
insets = {left = 4, right = 4, top = 4, bottom = 4},
}
editbox:SetBackdropColor(.1,.1,.1,1)
editbox:SetMultiLine(true)
editbox:SetAutoFocus(false)
editbox:SetScript("OnTextSet", function(self)
if self:GetText() == "" then
editbox:SetPoint("BOTTOMRIGHT", panel, "TOPRIGHT", -15, -100)
else
editbox:SetPoint("BOTTOMRIGHT", panel, "TOPRIGHT", -15, -325)
editbox:SetFocus()
editbox:HighlightText()
end
end)
editbox:SetScript("OnEscapePressed", editbox.ClearFocus)
editbox:SetScript("OnEditFocusLost", function(editbox) editbox:SetText("") end)
 
f:SetPoint("TOPLEFT", editbox, "BOTTOMLEFT")
f:EnableMouseWheel(true)
f:SetScript("OnHide", f.ScrollToBottom)
f:SetScript("OnHyperlinkClick", function(frame, link, text)
local _, _, msg = string.find(link, "tekerr:(.+)")
editbox:SetText(text.. "\n".. msg)
end)
f:SetScript("OnMouseWheel", function(frame, delta)
if delta > 0 then
if IsShiftKeyDown() then frame:ScrollToTop()
else frame:ScrollUp() end
elseif delta < 0 then
if IsShiftKeyDown() then frame:ScrollToBottom()
else frame:ScrollDown() end
end
end)
 
self:SetScript("OnShow", nil)
end)
 
 
-----------------------------
-- Slash Handler --
-----------------------------
 
SLASH_TEKERR1 = "/err"
SLASH_TEKERR2 = "/tekerr"
function SlashCmdList.TEKERR()
if panel:IsShown() then HideUIPanel(panel)
else ShowUIPanel(panel) end
end
 
 
----------------------------------------
-- Quicklaunch registration --
----------------------------------------
 
local ldb = LibStub and LibStub:GetLibrary("LibDataBroker-1.1", true)
if ldb then
ldb:NewDataObject("tekErr", {
type = "launcher",
icon = "Interface\\Icons\\Ability_Creature_Cursed_04",
OnClick = SlashCmdList.TEKERR,
})
end