-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDcr_DIAG.lua
1201 lines (937 loc) · 44.2 KB
/
Dcr_DIAG.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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--[[
This file is part of Decursive.
Decursive (v @project-version@) add-on for World of Warcraft UI
Copyright (C) 2006-2025 John Wellesz (Decursive AT 2072productions.com) ( http://www.2072productions.com/to/decursive.php )
Decursive is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Decursive is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Decursive. If not, see <https://www.gnu.org/licenses/>.
Decursive is inspired from the original "Decursive v1.9.4" by Patrick Bohnet (Quu).
The original "Decursive 1.9.4" is in public domain ( www.quutar.com )
Decursive is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
This file was last updated on @file-date-iso@
--]]
-------------------------------------------------------------------------------
local _G = _G;
local GetFramerate = _G.GetFramerate;
local GetNetStats = _G.GetNetStats;
local GetRealZoneText = _G.GetRealZoneText;
local tostring = _G.tostring;
local tonumber = _G.tonumber;
local select = _G.select;
local table = _G.table;
local GetTime = _G.GetTime;
local strjoin = _G.strjoin;
local GetCVarBool = _G.GetCVarBool;
local IsAddOnLoaded = _G.C_AddOns and _G.C_AddOns.IsAddOnLoaded or _G.IsAddOnLoaded;
local GetAddOnMetadata = _G.C_AddOns and _G.C_AddOns.GetAddOnMetadata or _G.GetAddOnMetadata;
local GetAddOnInfo = _G.C_AddOns and _G.C_AddOns.GetAddOnInfo or _G.GetAddOnInfo;
local GetNumAddOns = _G.C_AddOns and _G.C_AddOns.GetNumAddOns or _G.GetNumAddOns;
local time = _G.time;
local pcall = _G.pcall;
local pairs = _G.pairs;
local ipairs = _G.ipairs;
local InCombatLockdown = _G.InCombatLockdown;
local GetSpellInfo = _G.C_Spell and _G.C_Spell.GetSpellInfo or _G.GetSpellInfo;
local GetSpellName = _G.C_Spell and _G.C_Spell.GetSpellName or function (spellId) return (GetSpellInfo(spellId)) end;
local GetItemInfo = _G.C_Item and _G.C_Item.GetItemInfo or _G.GetItemInfo;
local addonName, T = ...;
DecursiveRootTable = T; -- needed until we get rid of the xml based UI. -- Also used by HHTD from 2013-04-05
-- a necessray compatibility layer between WoW 9 and WoW classic since we still have old xml UI stuff
DecursiveTemplateMixin = BackdropTemplateMixin and BackdropTemplateMixin or {
OnBackdropLoaded = function() end;
OnBackdropSizeChanged = function() end;
}
T._FatalError_Diaplayed = false;
-- big ugly scary fatal error message display function - only used when nothing else works {{{
T._FatalError = function (TheError)
if not StaticPopupDialogs["DECURSIVE_ERROR_FRAME"] then
StaticPopupDialogs["DECURSIVE_ERROR_FRAME"] = {
text = "|cFFFF0000Decursive Fatal Error:|r\n%s",
button1 = "OK",
OnAccept = function()
T._FatalError_Diaplayed = false;
return false;
end,
timeout = 0,
whileDead = 1,
hideOnEscape = 1,
showAlert = 1,
preferredIndex = 3,
};
end
if not T._FatalError_Diaplayed then
StaticPopup_Show ("DECURSIVE_ERROR_FRAME", TheError);
if T._DiagStatus then
T._FatalError_Diaplayed = true;
end
end
end
-- }}}
DecursiveInstallCorrupted = false;
T._C = {};
T._DebugTextTable = {};
T._DebugText = "";
T._DebugTimerRefName = "";
-- fail safes, T.Dcr will be replaced by AceAddon in normal conditions
-- Just add this so that diag functions can work even in the most dramatic events
T.Dcr = {};
local DC = T._C;
DC.UI_BACKDROP = {
bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
tile = true, tileSize = 16, edgeSize = 16,
insets = { left = 3, right = 5, top = 5, bottom = 5 }
}
local DebugTextTable = T._DebugTextTable;
local Reported = {};
local UNPACKAGED = "@pro" .. "ject-version@";
local VERSION = "@project-version@";
if not T._LoadedFiles then
T._LoadedFiles = {};
end
T._LoadedFiles["Dcr_DIAG.lua"] = false; -- here for consistency but useless in this particular file
if DecursiveInEmbeddedMode == nil then
T._EmbeddedMode = "unknown";
else
T._EmbeddedMode = DecursiveInEmbeddedMode;
DecursiveInEmbeddedMode = nil;
T._LoadedFiles["embeds.xml"] = DecursiveEmbedsxmlCheck;
DecursiveEmbedsxmlCheck = nil;
end
-- a list of all source files part of Decursive sort in loading order
T._LoadOrderedFiles = { -- {{{
"Dcr_preload.lua",
"embeds.xml",
"Dcr_DIAG.xml",
"Dcr_DIAG.lua",
"load.xml",
"enUS.lua",
"deDE.lua",
"esES.lua",
"esMX.lua",
"frFR.lua",
"koKR.lua",
"ruRU.lua",
"zhCN.lua",
"zhTW.lua",
"ptBR.lua",
"itIT.lua",
"DCR_init.lua",
"Dcr_LDB.lua",
"Dcr_utils.lua",
"Dcr_opt.lua",
"Dcr_Events.lua",
"Dcr_Raid.lua",
"Decursive.lua",
"Decursive.xml",
"Dcr_lists.lua",
"Dcr_lists.xml",
"Dcr_DebuffsFrame.lua",
"Dcr_DebuffsFrame.xml",
"Dcr_LiveList.lua",
"Dcr_LiveList.xml",
}; -- }}}
DC.StartTime = GetTime();
-- local utility functions {{{
local function _Debug (...)
if T.Dcr and T.Dcr.Debug and T.Dcr.debug then
T.Dcr:Debug(...);
end
end
local function _Print (...)
if T.Dcr and T.Dcr.Print then
T.Dcr:Print(...);
end
end
local function NiceTime()
return tonumber(("%.4f"):format(GetTime() - DC.StartTime));
end
local function print(t)
if DEFAULT_CHAT_FRAME then
DEFAULT_CHAT_FRAME:AddMessage(t);
end
end
-- taken from AceConsole-2.0
local function tostring_args(a1, ...)
if select('#', ...) < 1 then
return tostring(a1)
end
return tostring(a1), tostring_args(...)
end
-- }}}
-- DEBUG REPORTING {{{
function T._AddDebugText(a1, ...) -- {{{
_Debug("Error processed");
local text = "";
if select('#', ...) > 0 then
text = strjoin(", ", tostring_args(a1, ...))
else
text = tostring(a1);
end
local zone = GetRealZoneText() or "none";
if not Reported[text] then
table.insert (DebugTextTable, ("\n\n|cffff0000*****************|r\n\n%.4f (tr:'%s' ca:'%s' icl:'%s' h%d_w%d-%dfps-%s): %s -|count: "):format(
NiceTime(), -- %.4f
tostring(T._DebugTimerRefName), -- tr:'%s'
tostring(T._CatchAllErrors), -- ca:'%s'
tostring(InCombatLockdown()), -- icl:'%s'
select(3, GetNetStats()), -- h%d
select(4, GetNetStats()), -- w%d
GetFramerate(), -- %dfps
zone, -- -%s
text -- %s
));
table.insert (DebugTextTable, 1);
Reported[text] = #DebugTextTable;
else
DebugTextTable[Reported[text]] = DebugTextTable[Reported[text]] + 1;
end
-- if an error is caught while Decursive is being loaded, there is a good chance it will cancel loading alltogether.
-- So just display what we caught straight away.
if not T.Dcr.DcrFullyInitialized then
T._ShowDebugReport();
end
end -- }}}
function T._DebugFrameOnTextChanged(frame) -- {{{
-- inspired from BugSack
if frame:GetText() ~= T._DebugText then
frame:SetText(T._DebugText)
end
frame:GetParent():UpdateScrollChildRect()
local _, m = DecursiveDebuggingFrameScrollScrollBar:GetMinMaxValues()
if m > 0 and frame.max ~= m then
frame.max = m
DecursiveDebuggingFrameScrollScrollBar:SetValue(0)
end
end -- }}}
do
local DebugHeader = false;
local ReportEmail = GetAddOnMetadata("Decursive", "X-eMail") or "[email protected]";
local HeaderFailOver = ("|cFF11FF33Please email the content of this window to <%s>|r\n|cFF009999(Use CTRL+A to select all and then CTRL+C to put the text in your clip-board)|r\nAlso tell in your report if you noticed any strange behavior of Decursive.\n"):format(ReportEmail:gsub('@','+ReportFH@'));
local LoadedAddonNum = 0;
local TotalAddonMemoryUsage = 0;
local function GetAddonListAsString ()
local addonCount = GetNumAddOns();
local loadedAddonList = {};
local version, memoryUsage, name, security, _;
TotalAddonMemoryUsage = 0;
UpdateAddOnMemoryUsage();
for addonID=1, addonCount do
name, _, _, _, _, security, _ = GetAddOnInfo(addonID)
if security == 'INSECURE' and IsAddOnLoaded(addonID) then
version = GetAddOnMetadata(addonID, "Version");
memoryUsage = GetAddOnMemoryUsage(addonID);
TotalAddonMemoryUsage = TotalAddonMemoryUsage + memoryUsage;
table.insert(loadedAddonList, ("%s (%s)[%d]{MU: %d}"):format(name, version or 'N/A', addonID, memoryUsage));
end
end
table.sort(loadedAddonList);
LoadedAddonNum = #loadedAddonList;
return table.concat(loadedAddonList, "\n");
end
local function setReportHeader(fromDiag)
local instructionsHeader;
if fromDiag or not T.Dcr.db or not T.Dcr.db.global.NewerVersionName or T._HHTDErrors ~= 0 then
if T.Dcr.L and T.Dcr.L["DEBUG_REPORT_HEADER"] then
-- Create the header insterting the email address and
-- influencing the content if this is an HHTD error.
instructionsHeader = (T.Dcr.L["DEBUG_REPORT_HEADER"]):format(
ReportEmail:gsub('@', T._HHTDErrors ~= 0 and '+HHTDReport@' or '+Report@'),
T._HHTDErrors ~= 0 and 'Decursive / H.H.T.D.' or 'Decursive'
);
else
instructionsHeader = HeaderFailOver
end
else
instructionsHeader = T.Dcr.L and ((T.Dcr.L["DECURSIVE_DEBUG_REPORT_BUT_NEW_VERSION"]):format(T.Dcr.db.global.NewerVersionName)) or HeaderFailOver;
-- disable bug me not since the user _clearly_ took the wrong decision
T.Dcr.db.global.NewVersionsBugMeNot = false;
end
local TIandBI = T.Dcr.GetTimersInfo and {T.Dcr:GetTimersInfo()} or {-1,-1,-1,-1,-1,0};
TIandBI[#TIandBI + 1], TIandBI[#TIandBI + 2], TIandBI[#TIandBI + 3], TIandBI[#TIandBI + 4] = GetBuildInfo();
_Debug(unpack(TIandBI));
local dbcgd = T.Dcr.db and T.Dcr.db.global.delayedDebuffOccurences or -1
local dbcld = T.Dcr.Status and T.Dcr.Status.delayedDebuffOccurences or -1
local dbcgud = T.Dcr.db and T.Dcr.db.global.delayedUnDebuffOccurences or -1
local dbclud = T.Dcr.Status and T.Dcr.Status.delayedUnDebuffOccurences or -1
DebugHeader = ("%s\n@project-version@ %s(%s) CT: %0.4f D: %s %s %s DTl: %d DE: %d nDrE: %d Embeded: %s W: %d (LA: %d TAMU: %d) TA: %d NDRTA: %d BUIE: %d dbc: [d:%d-%d, u:%d-%d] TI: [dc:%d, lc:%d, y:%d, LEBY:%d, LB:%d, TTE:%u] (%s, %s, %s, %s)"):format(instructionsHeader, -- "%s\n
tostring(DC.MyClass), tostring(UnitLevel("player") or "??"), NiceTime(), date(), GetLocale(), -- %s(%s) CT: %0.4f D: %s %s
BugGrabber and "BG" .. (T.BugGrabber and "e" or "") or "NBG", -- %s
#DebugTextTable / 2, -- DTl: %d
T._DecursiveErrors, -- DE: %d
T._NonDecursiveErrors, -- nDrE: %d
tostring(T._EmbeddedMode), -- Embeded: %s
IsWindowsClient() and 1 or 0, -- W: %d
LoadedAddonNum, -- LA: %d
TotalAddonMemoryUsage, -- TAMU: %d
T._TaintingAccusations, -- TA: %d
T._NDRTaintingAccusations, -- NDRTA: %d
T._BlizzardUIErrors, -- BUIE: %d
dbcgd, dbcld, dbcgud, dbclud,
unpack(TIandBI)
-- T.Dcr:GetTimersInfo(), -- TI: [dc:%d, lc:%d, y:%d, LEBY:%d, LB:%d, TTE:%u]
-- GetBuildInfo()); -- (%s, %s, %s, %s)
);
end
function T._ShowDebugReport(fromDiag)
local diagStatus, PBCK = T._SelfDiagnostic();
if PBCK then
return;
end
if T._HHTDErrors == 0 and not fromDiag and DC.DevVersionExpired and T.Dcr.VersionWarnings then
T.Dcr:VersionWarnings(true);
return;
end
-- get running add-ons list
local ALASsuccess, loadedAddonList = pcall(GetAddonListAsString);
local ACsuccess, actionsConfiguration = pcall(T._ExportActionsConfiguration);
local BCsuccess, bleedConfiguration = pcall(function ()
local D = T.Dcr;
local knownBleedEffectsCount = 0;
for _ in pairs(D.Status.t_CheckBleedDebuffsActiveIDs) do
knownBleedEffectsCount = knownBleedEffectsCount + 1;
end
return ([=[%d Bleed Effects registered.
Bleed keywords:
---
%s
---
Active no case version:
---
%s
---]=]):format(
knownBleedEffectsCount,
tostring(D.db.locale.BleedEffectsKeywords),
tostring(D.Status.P_BleedEffectsKeywords_noCase)
)
end);
local CSCsuccess, customSpellConfiguration = pcall(T._ExportCustomSpellConfiguration);
local STPsuccess, spellTable = pcall(T._PrintSpellTable);
local SRTOLEsuccess, SRTOLErrors =
pcall(function() return T.Dcr:tAsString(T.Dcr.db.global.SRTLerrors) end);
local headerSucess, headerGenErrorm;
if not DebugHeader then
headerSucess, headerGenErrorm = pcall(setReportHeader, fromDiag);
else
headerSucess = true;
end
local SEP = "\n\n-- --\n\n";
T._DebugText = (headerSucess and DebugHeader or (HeaderFailOver .. 'Report header gen failed: ' .. (headerGenErrorm and headerGenErrorm or "")))
.. table.concat(T._DebugTextTable, "")
.. SEP .. "Bleed Conf:\n" .. bleedConfiguration .. SEP
.. "Action Conf:\n" .. actionsConfiguration .. SEP -- (Spells assignments:)
.. "Custom Spell Conf:\n" .. customSpellConfiguration .. SEP
.. "Decursive known spells:\n" .. spellTable .. SEP
.. "Script ran too long errors:\n" .. SRTOLErrors .. SEP
.. "\n\nLoaded Addons:\n\n" .. loadedAddonList .. SEP;
if _G.DecursiveDebuggingFrameText then
_G.DecursiveDebuggingFrameText:SetText(T._DebugText);
local title = T.Dcr.L and T.Dcr.L["DECURSIVE_DEBUG_REPORT"] or "**** |cFFFF0000Decursive Debug Report|r ****";
if T._HHTDErrors ~= 0 then
title = title:gsub('ecursive', 'ecursive / H.H.T.D.');
end
_G.DecursiveDEBUGtext:SetText(title);
_G.DecursiveDebuggingFrame:Show();
else
T._FatalError(T._DebugText);
end
end
end -- }}}
-- Decursive LUA error manager and debug reporting functions {{{
local function PlaySoundFile_RanTooLongheck(message)
-- test for PlaySoundFile() API call failure, this exception bubles in the
-- dispatcher so eat all errors happenning in the same refresh event (while
-- GetTime() stays the same)
if T._PlayingASound and T._PlayingASound == GetTime() and message:find("ran too long") then
_Debug('"Script ran too long" while playing sound eaten');
_Print("|cffff0000*DING!*|r (Decursive failed to play a sound)");
return true;
end
return false;
end
local function CheckHHTD_Error(errorm, errorml)
if (errorml:find("hhtd") and not errorml:find("[\\/]libs[\\/]"))
or
(errorml:find("\\libnameplateregistry") and not errorml:find("couldn't open") and not errorml:find("error loading")) then
_Debug("CheckHHTD_Error()", true);
return true;
end
return false;
end
local AddDebugText = T._AddDebugText;
-- The error handler
-- used to prevent loops if our own error handler crashes
local IsReporting = false;
T._NonDecursiveErrors = 0;
T._DecursiveErrors = 0;
T._TaintingAccusations = 0;
T._NDRTaintingAccusations = 0;
T._BlizzardUIErrors = 0;
T._ErrorLimitStripped = false;
T._HHTDErrors = 0;
local LastErrorMessage = "!NotSet!";
-- a special handler for these random "Script ran too long" error
-- returns true when a resport should be shown, false otherwise
local function continueErrorReporting (lowerCaseErrorMsg)
local isSRTLE = lowerCaseErrorMsg:find("script ran too long")
if not isSRTLE then
-- continue as usual when this error is not a SRTL one
return true;
elseif T._CatchAllErrors or not T.Dcr.DcrFullyInitialized then
-- However we do want to catch SRTL errors when these flags are active as it
-- explains why subsequent "impossible" errors are happening...
-- (several reports were received where DCR init did not complete for no apparent reason)
return true;
end
-- these tests appear to be redundant but this function must never crash...
if not T.Dcr.db or not T.Dcr.db.global or not T.Dcr.db.global.SRTLerrors then
return false;
end
local fname_line = lowerCaseErrorMsg:match('(%w+%.[xl][mu][la]:%d+)');
if not fname_line then
return false;
end
local SRTLerrors = T.Dcr.db.global.SRTLerrors;
SRTLerrors["total"] = SRTLerrors["total"] + 1;
if not SRTLerrors[fname_line] then
SRTLerrors[fname_line] = {};
end
local ctime = time();
while(SRTLerrors[fname_line][1] and ctime - SRTLerrors[fname_line][1] > 86400 * 30) do
table.remove(SRTLerrors[fname_line], 1);
end
table.insert(SRTLerrors[fname_line], ctime);
if lowerCaseErrorMsg:find("dcr_diag.lua") then
return false;
end
if #SRTLerrors[fname_line] > 1 then
return true;
else
return false;
end
end
function T._onError(event, errorObject)
local errorm = errorObject.message;
local mine = false;
local taintingAccusation = false;
-- test for PlaySoundFile() API call failure
if PlaySoundFile_RanTooLongheck(errorm) then
return;
end
local errorml = errorm:lower();
if not IsReporting
and ( T._CatchAllErrors or (
errorml:find("decursive") and -- first, make a general test to see if it's worth looking further
(
( not errorml:find("[\\/]libs[\\/]") ) -- errors happpening in something located below Decursive's path but not inside \Libs
or ( errorm:find("[\"']Decursive[\"']") ) -- events involving Decursive
or ( errorm:find("Decursive:") ) -- libraries error involving Decursive (AceLocal)
or ( errorml:find("decursive%.")) -- for Aceconfig
)
)) then
if not continueErrorReporting(errorml) then
return;
end
-- Ignore errors caused by corrupted savedVariables files
if errorm:find("SavedVariables") then
return;
end
if errorm:find("ADDON_ACTION_") then
taintingAccusation = true;
end
if not taintingAccusation or T._EmbeddedMode == false then -- if we are having this while we're not emebedding anything then it does matters
IsReporting = true;
AddDebugText(errorObject.message, "\n|cff00aa00STACK:|r\n", errorObject.stack, "\n|cff00aa00LOCALS:|r\n", errorObject.locals);
IsReporting = false;
T._CatchAllErrors = false; -- Errors are unacceptable so one is enough, no need to get all subsequent errors.
mine = true;
_Debug("Lua error recorded");
T._DecursiveErrors = T._DecursiveErrors + 1;
else
T._NonDecursiveErrors = T._NonDecursiveErrors + 1;
T._TaintingAccusations = T._TaintingAccusations + 1;
_Debug("False tainting accusation put under the carpet");
return; -- bury it under the carpet since it's blaming the wrong add-on and misleading the users.
end
else -- not a Decursive error
if IsReporting then
IsReporting = false;
else
T._NonDecursiveErrors = T._NonDecursiveErrors + 1;
if CheckHHTD_Error(errorm, errorml) then
if not continueErrorReporting(errorml) then
return;
end
IsReporting = true;
AddDebugText(errorObject.message, "\n|cff00aa00STACK:|r\n", errorObject.stack, "\n|cff00aa00LOCALS:|r\n", errorObject.locals);
IsReporting = false;
T._HHTDErrors = T._HHTDErrors + 1;
mine = true;
elseif errorm:find("ADDON_ACTION_") then
T._NDRTaintingAccusations = T._NDRTaintingAccusations + 1;
elseif errorm:find("FrameXML") or errorm:find("SharedXML") then
T._BlizzardUIErrors = T._BlizzardUIErrors + 1;
end
end
end
LastErrorMessage = errorm;
if not mine and not T._BugSackLoaded then
--/console scriptErrors 1 to check it
if _G.DEBUGLOCALS_LEVEL then
-- Fix Blizzard's own code... (2017-09-04: it's set to 5 while it should be 4)
if _G.DEBUGLOCALS_LEVEL == 5 then
_G.DEBUGLOCALS_LEVEL = 4
end
_G.DEBUGLOCALS_LEVEL = _G.DEBUGLOCALS_LEVEL + 9
end
-- forward the error to the original error handler
if _G.HandleLuaError or T._OriginalDebugHandler then
local errorm = errorObject.message;
if _G.HandleLuaError then
_Debug("Lua error forwarded to Blizzard's handler");
return _G.HandleLuaError( errorm );
elseif T._OriginalDebugHandler and T._OriginalDebugHandler ~= geterrorhandler() then
_Debug("Lua error forwarded to original handler");
return T._OriginalDebugHandler ( errorm );
else
_Debug("Lua error could not be forwarded because the original error handler is no longer available.");
end
else
_Debug("Lua error NOT forwarded because no original error handler was found!");
end
else
_Debug("Lua error NOT forwarded, mine=", mine, "BugSack loaded:", T._BugSackLoaded);
end
end
local ProperErrorHandler = false;
local _, _, _, tocversion = GetBuildInfo();
T._CatchAllErrors = false;
T._tocversion = tocversion;
DC.WOWC = WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE
DC.WOTLK = WOW_PROJECT_WRATH_CLASSIC ~= nil and WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC -- https://wowpedia.fandom.com/wiki/WOW_PROJECT_ID
DC.CATACLYSM = WOW_PROJECT_CATACLYSM_CLASSIC ~= nil and WOW_PROJECT_ID >= WOW_PROJECT_CATACLYSM_CLASSIC
DC.TWW = tocversion >= 110000
function T._DecursiveErrorHandler(err, ...)
if T._ErrorLimitStripped then
return;
end
err = tostring(err);
local errl = err:lower();
if PlaySoundFile_RanTooLongheck(err) then
return;
end
local mine = false;
-- adapted from Blizzard
local currentStackHeight = GetCallstackHeight and GetCallstackHeight() or 3;
local errorCallStackHeight = GetErrorCallstackHeight and GetErrorCallstackHeight() or currentStackHeight - 2;
local errorStackOffset = errorCallStackHeight and (errorCallStackHeight - 1);
local debugStackLevel = currentStackHeight - (errorStackOffset or 0);
--
_Debug("GetCallstackHeight: ", GetCallstackHeight(), "GetErrorCallstackHeight:", GetErrorCallstackHeight(), "computed stackLevel:", debugStackLevel);
if not IsReporting and (T._CatchAllErrors or errl:find("decursive") and not errl:find("[\\/]libs[\\/]")) then
if not continueErrorReporting(errl) then
return;
end
-- Ignore errors caused by corrupted savedVariables files
if err:find("SavedVariables") then
return;
end
IsReporting = true;
AddDebugText(err, "\n|cff00aa00STACK:|r\n", debugstack(debugStackLevel), "\n|cff00aa00LOCALS:|r\n", debuglocals(debugStackLevel), ...);
IsReporting = false;
T._CatchAllErrors = false; -- Errors are unacceptable so one is enough, no need to get all subsequent errors.
mine = true;
_Debug("Error recorded");
else
if IsReporting then -- then it means there is a bug inside AddDebugText...
IsReporting = false;
else
T._NonDecursiveErrors = T._NonDecursiveErrors + 1;
if CheckHHTD_Error(err, errl) then
if not continueErrorReporting(errl) then
return;
end
IsReporting = true;
AddDebugText(err, "\n|cff00aa00STACK:|r\n", debugstack(3), "\n|cff00aa00LOCALS:|r\n", debuglocals(3), ...);
IsReporting = false;
T._HHTDErrors = T._HHTDErrors + 1;
mine = true;
elseif err:find("ADDON_ACTION_") then
T._NDRTaintingAccusations = T._NDRTaintingAccusations + 1;
elseif err:find("FrameXML") or err:find("SharedXML") then
T._BlizzardUIErrors = T._BlizzardUIErrors + 1;
end
if (T._NonDecursiveErrors - T._NDRTaintingAccusations - T._BlizzardUIErrors) > 999 then
T._ErrorLimitStripped = NiceTime() > 10; -- allow a graceful period of 10s after startup
T._TooManyErrors();
end
end
end
LastErrorMessage = err;
if ProperErrorHandler and not mine then
if _G.DEBUGLOCALS_LEVEL then
-- Fix Blizzard's own code... (2017-09-04: it's set to 5 while it should be 4)
if _G.DEBUGLOCALS_LEVEL == 5 then
_G.DEBUGLOCALS_LEVEL = 4
end
_G.DEBUGLOCALS_LEVEL = _G.DEBUGLOCALS_LEVEL + 3;
end
return ProperErrorHandler( err, ... ); -- returning this way prevents this function from appearing in the stack
end
end
local WarningDisplayed = false;
function T._TooManyErrors()
-- T._NDRTaintingAccusations
-- If the game just started (or Decursive), we ignore error burst as the
-- new LUA_WARNING feature reveals many loading issues in other add-ons
-- without gameplay consequences
if (NiceTime() > 10) then
-- if tainting accusation and Blizzard's UI errors represent more than 90% of errors then yield and don't display anything
if not ((T._NDRTaintingAccusations + T._BlizzardUIErrors) > T._NonDecursiveErrors * 0.9) then
if not WarningDisplayed and T.Dcr and T.Dcr.L and not (#DebugTextTable > 0 or T._TaintingAccusations > 10) then -- if we can and should display the alert
_Print(T.Dcr:ColorText((T.Dcr.L["TOO_MANY_ERRORS_ALERT"]):format(T._NonDecursiveErrors), "FFFF0000"));
_Print(T.Dcr:ColorText(T.Dcr.L["DONT_SHOOT_THE_MESSENGER"], "FFFF9955"));
_Print('|cFF47C2A1Here is the last non-Decursive UI error:|r', LastErrorMessage);
WarningDisplayed = true;
end
else
_Debug("_TooManyErrors()'s message not displayed NDR-TA being predominent...");
end
else
_Debug("_TooManyErrors()'s message not displayed Decursive was just started...");
end
_Debug("Error handler disabled");
end
function T._RegisterBugGrabberCallBacks()
if not BugGrabber.RegisterCallback then
return;
end
local ok, errorm = pcall (BugGrabber.RegisterCallback, T, "BugGrabber_BugGrabbed", T._onError)
if ok then
T._BugGrabberEmbeded = true;
else
T._BugGrabberEmbeded = false;
AddDebugText("pcall hook 1: "..errorm, BugGrabber);
end
ok, errorm = pcall (BugGrabber.RegisterCallback, T, "BugGrabber_CapturePaused", T._TooManyErrors)
if ok then
T._BugGrabberThrottleAlert = true;
else
AddDebugText("pcall hook 2: "..errorm);
end
return T._BugGrabberEmbeded;
end
function T._HookErrorHandler()
if BugGrabber then
local loading, loaded = IsAddOnLoaded("BugSack");
if loaded then
T._BugSackLoaded = _G.BugSack and _G.BugSack.healthCheck or false;
else
T._BugSackLoaded = false;
end
BUGGRABBER_SUPPRESS_THROTTLE_CHAT = true; -- for people using an older version of BugGrabber. There is no way to know...
-- force BG to load callbackhandler since it relies on other add-ons that embeded it.
if not BugGrabber.RegisterCallback and BugGrabber.setupCallbacks then
BugGrabber.setupCallbacks();
end
return T._RegisterBugGrabberCallBacks();
end
-- if no buggrabber is found then use the old way (no other error catcher is as good as BugGrabber... I can't rely on them)
if not ProperErrorHandler then
ProperErrorHandler = geterrorhandler();
seterrorhandler(T._DecursiveErrorHandler);
end
return true;
end
--}}}
T._ShowNotice = function (notice)
if not StaticPopupDialogs["DECURSIVE_NOTICE_FRAME"] then
-- the beautiful notice popup : {{{ -
StaticPopupDialogs["DECURSIVE_NOTICE_FRAME"] = {
text = "|cFFFF0000Decursive Notice:|r\n%s",
button1 = "OK",
OnAccept = function()
return false;
end,
timeout = 0,
whileDead = 1,
hideOnEscape = false,
showAlert = 1,
preferredIndex = 3,
}; -- }}}
if T.Dcr.L and T.Dcr.L["NOTICE_FRAME_TEMPLATE"] and T.Dcr.L["NOTICE_FRAME_TEMPLATE"]:find("%s") then
StaticPopupDialogs["DECURSIVE_NOTICE_FRAME"].text = T.Dcr.L["NOTICE_FRAME_TEMPLATE"];
end
end
StaticPopup_Show ("DECURSIVE_NOTICE_FRAME", notice);
end
-- SELF DIAGNOSTIC {{{
do
T._DiagStatus = false;
local PrintMessage = function (message, ...) if T._DiagStatus ~= 2 then _Print("|cFFFFAA55Self diagnostic:|r ", format(message, ...)); end end;
function T._ExportCustomSpellConfiguration () -- (use pcall with this) -- {{{
local errorPrefix = function (message)
return "_ExportCustomSpellConfiguration: " .. message;
end
local customSpellConfText = {};
local D = T.Dcr;
if not D.classprofile or not D.classprofile.UserSpells then
return errorPrefix("D.classprofile.UserSpells not available");
end
for spellID, spellData in pairs(D.classprofile.UserSpells) do
if not spellData.IsDefault then
customSpellConfText[#customSpellConfText + 1] = (" %s (id: %s) - %s - %s - %s - B: %d - Ts: %s - UF: %s - Macro: %s\n"):format(
-- 3 4 5 6 7 8 9
select (2, pcall(function () return tostring(spellData.IsItem and (GetItemInfo(spellID * -1)) or GetSpellName(spellID)) end)), tostring(spellID),
spellData.Disabled and "OFF" or "ON", -- 3
spellData.Pet and "PET" or "PLAYER", -- 4
spellData.IsItem and "ITEM" or "SPELL", -- 5
spellData.Better, -- 6
D:tAsString(spellData.Types), -- 7
D:tAsString(spellData.UnitFiltering), -- 8
spellData.MacroText and spellData.MacroText or "false" -- 9
);
end
end
return table.concat(customSpellConfText, "\n");
end
function T._PrintSpellTable() -- (use pcall with this) -- {{{
local errorPrefix = function (message)
return "_PrintSpellTable: " .. message;
end
local customSpellConfText = {};
local D = T.Dcr;
if not T._C or not T._C.DSI then
return errorPrefix("T._C.DSI not available");
end
return "\n(left and right side should be 'matching')\n" .. D:tAsString(D:tMap(T._C.DSI, GetSpellName));
end
function T._ExportActionsConfiguration () -- (use pcall with this) -- {{{
local errorPrefix = function (message)
return "_ExportActionsConfiguration: " .. message;
end
local SpellAssignmentsTexts = {};
local D = T.Dcr;
if not D.Status then
return errorPrefix("D.Status not available");
end
local sucess, MouseButtons = pcall(function ()return D.db.global.MouseButtons end);
if not sucess then
return errorPrefix("couldn't get MouseButtons: " .. MouseButtons);
end
SpellAssignmentsTexts[1] = "\nSpells assignments:";
for Spell, Prio in pairs(D.Status.CuringSpellsPrio) do
local SpellCuredTypes = {};
for typeprio, afflictionType in ipairs(D.Status.ReversedCureOrder) do
if D.Status.CuringSpells[afflictionType] == Spell then
table.insert(SpellCuredTypes, DC.TypeToLocalizableTypeNames[afflictionType])
end
end
SpellCuredTypes = table.concat (SpellCuredTypes, " - ");
SpellAssignmentsTexts[Prio + 1] = string.format("\n %s -> %s%s", ("%s - %s - (%s)"):format( ("Prio %d:"):format(Prio), SpellCuredTypes, MouseButtons[Prio]), Spell, (D.Status.FoundSpells[Spell] and D.Status.FoundSpells[Spell][5]) and ("\n MACRO(%d):(%s)"):format(D.Status.FoundSpells[Spell][5]:len(), D.Status.FoundSpells[Spell][5]) or "");
end
return table.concat(SpellAssignmentsTexts, "\n");
end -- }}}
local LibraryIssues = false; -- always a PBCK
local Incompatible = false; -- always a PBCK
local MixedInstall = false; -- always a PBCK
local MissingFile = false; -- always a PBCK
local RestartNeeded = false; -- always a PBCK
local IncompleteLoad = false; -- NOT always a PBCK
function T._SelfDiagnostic (force, FromCommand) -- {{{
-- will not executes several times unless forced
if not force and T._DiagStatus then
return T._DiagStatus, LibraryIssues or Incompatible or MixedInstall or MissingFile or RestartNeeded;
end
T._DiagStatus = 0; -- will be set to 1 if the diagnostic fails
-- Table with all the required libraries with their current revision at Decursive release time.
--LibStub:GetLibrary
local UseLibStub = {
["AceAddon-3.0"] = 13,
["AceComm-3.0"] = 14,
["AceConsole-3.0"] = 7,
["AceDB-3.0"] = 29,
["AceDBOptions-3.0"] = 15,
["AceEvent-3.0"] = 4,
["AceHook-3.0"] = 9,
["AceLocale-3.0"] = 6,
["AceTimer-3.0"] = 17,
["AceGUI-3.0"] = 41,
["AceConfig-3.0"] = 3,
["AceConfigCmd-3.0"] = 14,
["AceConfigDialog-3.0"] = 86,
["AceConfigRegistry-3.0"] = 21,
["LibDataBroker-1.1"] = 4,
["LibDBIcon-1.0"] = 55,
["LibQTip-1.0"] = 49,
["CallbackHandler-1.0"] = 8,
["LibDualSpec-1.0"] = (DC.CATACLYSM or not DC.WOWC) and 24 or nil,
};