Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Rob Anderson committed Sep 5, 2024
1 parent 2cb059a commit 51eb33f
Show file tree
Hide file tree
Showing 8 changed files with 436 additions and 85 deletions.
57 changes: 37 additions & 20 deletions AddonScope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,50 @@ G_RLF = {}
local addonName = "RPGLootFeed"
local dbName = addonName .. "DB"
local localeName = addonName .. "Locale"

local xpcall = xpcall

local function errorhandler(err)
local suffix = "\n\n==== Addon Info " .. G_RLF.addonName .. " " .. G_RLF.addonVersion .. " ====\n\n"
suffix = suffix .. G_RLF.L["Issues"] .. "\n\n"

return geterrorhandler()(err .. suffix)
end

function G_RLF:fn(func, ...)
-- Borrowed from AceAddon-3.0
if type(func) == "function" then
return xpcall(func, errorhandler, ...)
end
end

G_RLF.RLF = LibStub("AceAddon-3.0"):NewAddon(addonName, "AceConsole-3.0", "AceEvent-3.0", "AceHook-3.0", "AceTimer-3.0")
G_RLF.RLF:SetDefaultModuleState(true)
G_RLF.RLF:SetDefaultModulePrototype({
getLogger = function(self)
return G_RLF.RLF:GetModule("Logger")
end,
type = function(self)
if self then
return self.moduleName
fn = function(s, func, ...)
local function errorhandler(err)
local suffix = "\n\n==== Addon Info " .. G_RLF.addonName .. " " .. G_RLF.addonVersion .. " ====\n\n"
local status, trace = pcall(function()
return s:getLogger():Trace(s.moduleName)
end)
if status then
suffix = suffix .. "Log traces related to " .. s.moduleName .. "\n"
suffix = suffix .. "-------------------------------------------------\n"
suffix = suffix .. trace
suffix = suffix .. "-------------------------------------------------\n\n"
end
suffix = suffix .. G_RLF.L["Issues"] .. "\n\n"

return geterrorhandler()(err .. suffix)
end

-- Borrowed from AceAddon-3.0
if type(func) == "function" then
return xpcall(func, errorhandler, ...)
end
return nil
end,
})
G_RLF.addonName = addonName
Expand All @@ -31,19 +64,3 @@ G_RLF.DisableBossBanner = {
function G_RLF:Print(...)
G_RLF.RLF:Print(...)
end

local xpcall = xpcall

local function errorhandler(err)
local suffix = "\n\n==== Addon Info " .. G_RLF.addonName .. " " .. G_RLF.addonVersion .. " ====\n\n"
suffix = suffix .. G_RLF.L["Issues"] .. "\n\n"

return geterrorhandler()(err .. suffix)
end

function G_RLF:fn(func, ...)
-- Borrowed from AceAddon-3.0
if type(func) == "function" then
return xpcall(func, errorhandler, ...)
end
end
Loading

0 comments on commit 51eb33f

Please sign in to comment.