move old systemout to use errorhandler
This commit is contained in:
@@ -629,10 +629,18 @@ function Animation:update(dt, element)
|
|||||||
if self.onStart and type(self.onStart) == "function" then
|
if self.onStart and type(self.onStart) == "function" then
|
||||||
local success, err = pcall(self.onStart, self, element)
|
local success, err = pcall(self.onStart, self, element)
|
||||||
if not success then
|
if not success then
|
||||||
|
-- Use ErrorHandler if available via Animation module
|
||||||
|
if Animation._ErrorHandler then
|
||||||
|
Animation._ErrorHandler:warn("Animation", "EVT_002", {
|
||||||
|
callback = "onStart",
|
||||||
|
error = tostring(err),
|
||||||
|
})
|
||||||
|
else
|
||||||
print(string.format("[Animation] onStart error: %s", tostring(err)))
|
print(string.format("[Animation] onStart error: %s", tostring(err)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
dt = dt * self._speed
|
dt = dt * self._speed
|
||||||
|
|
||||||
@@ -645,9 +653,17 @@ function Animation:update(dt, element)
|
|||||||
if self.onComplete and type(self.onComplete) == "function" then
|
if self.onComplete and type(self.onComplete) == "function" then
|
||||||
local success, err = pcall(self.onComplete, self, element)
|
local success, err = pcall(self.onComplete, self, element)
|
||||||
if not success then
|
if not success then
|
||||||
|
-- Use ErrorHandler if available via Animation module
|
||||||
|
if Animation._ErrorHandler then
|
||||||
|
Animation._ErrorHandler:warn("Animation", "EVT_002", {
|
||||||
|
callback = "onComplete",
|
||||||
|
error = tostring(err),
|
||||||
|
})
|
||||||
|
else
|
||||||
print(string.format("[Animation] onComplete error: %s", tostring(err)))
|
print(string.format("[Animation] onComplete error: %s", tostring(err)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -678,9 +694,17 @@ function Animation:update(dt, element)
|
|||||||
if self.onComplete and type(self.onComplete) == "function" then
|
if self.onComplete and type(self.onComplete) == "function" then
|
||||||
local success, err = pcall(self.onComplete, self, element)
|
local success, err = pcall(self.onComplete, self, element)
|
||||||
if not success then
|
if not success then
|
||||||
|
-- Use ErrorHandler if available via Animation module
|
||||||
|
if Animation._ErrorHandler then
|
||||||
|
Animation._ErrorHandler:warn("Animation", "EVT_002", {
|
||||||
|
callback = "onComplete",
|
||||||
|
error = tostring(err),
|
||||||
|
})
|
||||||
|
else
|
||||||
print(string.format("[Animation] onComplete error: %s", tostring(err)))
|
print(string.format("[Animation] onComplete error: %s", tostring(err)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -691,9 +715,17 @@ function Animation:update(dt, element)
|
|||||||
local progress = self.elapsed / self.duration
|
local progress = self.elapsed / self.duration
|
||||||
local success, err = pcall(self.onUpdate, self, element, progress)
|
local success, err = pcall(self.onUpdate, self, element, progress)
|
||||||
if not success then
|
if not success then
|
||||||
|
-- Use ErrorHandler if available via Animation module
|
||||||
|
if Animation._ErrorHandler then
|
||||||
|
Animation._ErrorHandler:warn("Animation", "EVT_002", {
|
||||||
|
callback = "onUpdate",
|
||||||
|
error = tostring(err),
|
||||||
|
})
|
||||||
|
else
|
||||||
print(string.format("[Animation] onUpdate error: %s", tostring(err)))
|
print(string.format("[Animation] onUpdate error: %s", tostring(err)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@@ -1002,11 +1034,19 @@ function Animation:cancel(element)
|
|||||||
if self.onCancel and type(self.onCancel) == "function" then
|
if self.onCancel and type(self.onCancel) == "function" then
|
||||||
local success, err = pcall(self.onCancel, self, element)
|
local success, err = pcall(self.onCancel, self, element)
|
||||||
if not success then
|
if not success then
|
||||||
|
-- Use ErrorHandler if available via Animation module
|
||||||
|
if Animation._ErrorHandler then
|
||||||
|
Animation._ErrorHandler:warn("Animation", "EVT_002", {
|
||||||
|
callback = "onCancel",
|
||||||
|
error = tostring(err),
|
||||||
|
})
|
||||||
|
else
|
||||||
print(string.format("[Animation] onCancel error: %s", tostring(err)))
|
print(string.format("[Animation] onCancel error: %s", tostring(err)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--- Reset animation
|
--- Reset animation
|
||||||
function Animation:reset()
|
function Animation:reset()
|
||||||
@@ -1369,10 +1409,18 @@ function AnimationGroup:update(dt, element)
|
|||||||
if self.onStart and type(self.onStart) == "function" then
|
if self.onStart and type(self.onStart) == "function" then
|
||||||
local success, err = pcall(self.onStart, self)
|
local success, err = pcall(self.onStart, self)
|
||||||
if not success then
|
if not success then
|
||||||
|
-- Use ErrorHandler if available via AnimationGroup module
|
||||||
|
if AnimationGroup._ErrorHandler then
|
||||||
|
AnimationGroup._ErrorHandler:warn("AnimationGroup", "EVT_002", {
|
||||||
|
callback = "onStart",
|
||||||
|
error = tostring(err),
|
||||||
|
})
|
||||||
|
else
|
||||||
print(string.format("[AnimationGroup] onStart error: %s", tostring(err)))
|
print(string.format("[AnimationGroup] onStart error: %s", tostring(err)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local finished = false
|
local finished = false
|
||||||
|
|
||||||
@@ -1389,10 +1437,18 @@ function AnimationGroup:update(dt, element)
|
|||||||
if self.onComplete and type(self.onComplete) == "function" then
|
if self.onComplete and type(self.onComplete) == "function" then
|
||||||
local success, err = pcall(self.onComplete, self)
|
local success, err = pcall(self.onComplete, self)
|
||||||
if not success then
|
if not success then
|
||||||
|
-- Use ErrorHandler if available via AnimationGroup module
|
||||||
|
if AnimationGroup._ErrorHandler then
|
||||||
|
AnimationGroup._ErrorHandler:warn("AnimationGroup", "EVT_002", {
|
||||||
|
callback = "onComplete",
|
||||||
|
error = tostring(err),
|
||||||
|
})
|
||||||
|
else
|
||||||
print(string.format("[AnimationGroup] onComplete error: %s", tostring(err)))
|
print(string.format("[AnimationGroup] onComplete error: %s", tostring(err)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return finished
|
return finished
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -559,13 +559,19 @@ function Element.new(props)
|
|||||||
Element._Context.deferCallback(function()
|
Element._Context.deferCallback(function()
|
||||||
local success, callbackErr = pcall(self.onImageLoad, self, loadedImage)
|
local success, callbackErr = pcall(self.onImageLoad, self, loadedImage)
|
||||||
if not success then
|
if not success then
|
||||||
print(string.format("[Element] onImageLoad error: %s", tostring(callbackErr)))
|
Element._ErrorHandler:warn("Element", "EVT_002", {
|
||||||
|
callback = "onImageLoad",
|
||||||
|
error = tostring(callbackErr),
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
local success, callbackErr = pcall(self.onImageLoad, self, loadedImage)
|
local success, callbackErr = pcall(self.onImageLoad, self, loadedImage)
|
||||||
if not success then
|
if not success then
|
||||||
print(string.format("[Element] onImageLoad error: %s", tostring(callbackErr)))
|
Element._ErrorHandler:warn("Element", "EVT_002", {
|
||||||
|
callback = "onImageLoad",
|
||||||
|
error = tostring(callbackErr),
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -578,13 +584,19 @@ function Element.new(props)
|
|||||||
Element._Context.deferCallback(function()
|
Element._Context.deferCallback(function()
|
||||||
local success, callbackErr = pcall(self.onImageError, self, err or "Unknown error")
|
local success, callbackErr = pcall(self.onImageError, self, err or "Unknown error")
|
||||||
if not success then
|
if not success then
|
||||||
print(string.format("[Element] onImageError error: %s", tostring(callbackErr)))
|
Element._ErrorHandler:warn("Element", "EVT_002", {
|
||||||
|
callback = "onImageError",
|
||||||
|
error = tostring(callbackErr),
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
local success, callbackErr = pcall(self.onImageError, self, err or "Unknown error")
|
local success, callbackErr = pcall(self.onImageError, self, err or "Unknown error")
|
||||||
if not success then
|
if not success then
|
||||||
print(string.format("[Element] onImageError error: %s", tostring(callbackErr)))
|
Element._ErrorHandler:warn("Element", "EVT_002", {
|
||||||
|
callback = "onImageError",
|
||||||
|
error = tostring(callbackErr),
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -597,13 +609,19 @@ function Element.new(props)
|
|||||||
Element._Context.deferCallback(function()
|
Element._Context.deferCallback(function()
|
||||||
local success, callbackErr = pcall(self.onImageLoad, self, self.image)
|
local success, callbackErr = pcall(self.onImageLoad, self, self.image)
|
||||||
if not success then
|
if not success then
|
||||||
print(string.format("[Element] onImageLoad error: %s", tostring(callbackErr)))
|
Element._ErrorHandler:warn("Element", "EVT_002", {
|
||||||
|
callback = "onImageLoad",
|
||||||
|
error = tostring(callbackErr),
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
local success, callbackErr = pcall(self.onImageLoad, self, self.image)
|
local success, callbackErr = pcall(self.onImageLoad, self, self.image)
|
||||||
if not success then
|
if not success then
|
||||||
print(string.format("[Element] onImageLoad error: %s", tostring(callbackErr)))
|
Element._ErrorHandler:warn("Element", "EVT_002", {
|
||||||
|
callback = "onImageLoad",
|
||||||
|
error = tostring(callbackErr),
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -659,10 +659,28 @@ function MemoryScanner.saveReport(report, filename)
|
|||||||
if file then
|
if file then
|
||||||
file:write(formatted)
|
file:write(formatted)
|
||||||
file:close()
|
file:close()
|
||||||
|
-- Use ErrorHandler if available, otherwise fall back to print
|
||||||
|
if MemoryScanner._ErrorHandler then
|
||||||
|
MemoryScanner._ErrorHandler:warn("MemoryScanner", "RES_004", {
|
||||||
|
resourceType = "report",
|
||||||
|
path = filename,
|
||||||
|
status = "saved",
|
||||||
|
})
|
||||||
|
else
|
||||||
print(string.format("[MemoryScanner] Report saved to %s", filename))
|
print(string.format("[MemoryScanner] Report saved to %s", filename))
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- Use ErrorHandler if available, otherwise fall back to print
|
||||||
|
if MemoryScanner._ErrorHandler then
|
||||||
|
MemoryScanner._ErrorHandler:warn("MemoryScanner", "RES_004", {
|
||||||
|
resourceType = "report",
|
||||||
|
path = filename,
|
||||||
|
status = "failed to save",
|
||||||
|
})
|
||||||
else
|
else
|
||||||
print(string.format("[MemoryScanner] Failed to save report to %s", filename))
|
print(string.format("[MemoryScanner] Failed to save report to %s", filename))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return MemoryScanner
|
return MemoryScanner
|
||||||
|
|||||||
@@ -145,8 +145,16 @@ function Performance:stopTimer(name)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if self.logToConsole then
|
if self.logToConsole then
|
||||||
|
-- Use ErrorHandler if available, otherwise fall back to print
|
||||||
|
if self._ErrorHandler and self._ErrorHandler.warn then
|
||||||
|
self._ErrorHandler:warn("Performance", "PERF_001", {
|
||||||
|
metric = name,
|
||||||
|
elapsed = string.format("%.3fms", elapsed),
|
||||||
|
})
|
||||||
|
else
|
||||||
print(string.format("[Performance] %s: %.3fms", name, elapsed))
|
print(string.format("[Performance] %s: %.3fms", name, elapsed))
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return elapsed
|
return elapsed
|
||||||
end
|
end
|
||||||
@@ -284,9 +292,6 @@ function Performance:_addWarning(name, value, level)
|
|||||||
value = string.format("%.2fms", value),
|
value = string.format("%.2fms", value),
|
||||||
threshold = level == "critical" and self.criticalThresholdMs or self.warningThresholdMs,
|
threshold = level == "critical" and self.criticalThresholdMs or self.warningThresholdMs,
|
||||||
})
|
})
|
||||||
else
|
|
||||||
local prefix = level == "critical" and "[CRITICAL]" or "[WARNING]"
|
|
||||||
print(string.format("%s Performance: %s = %.2fms", prefix, name, value))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
self._shownWarnings[warningKey] = now
|
self._shownWarnings[warningKey] = now
|
||||||
@@ -409,11 +414,6 @@ function Performance:logWarning(warningKey, module, message, details, suggestion
|
|||||||
|
|
||||||
if self._ErrorHandler and self._ErrorHandler.warn then
|
if self._ErrorHandler and self._ErrorHandler.warn then
|
||||||
self._ErrorHandler:warn(module, "PERF_001", details or {})
|
self._ErrorHandler:warn(module, "PERF_001", details or {})
|
||||||
else
|
|
||||||
print(string.format("[FlexLove - %s] Performance Warning: %s", module, message))
|
|
||||||
if suggestion then
|
|
||||||
print(string.format(" Suggestion: %s", suggestion))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -538,8 +538,6 @@ function StateManager.getStats()
|
|||||||
expected = "near 0",
|
expected = "near 0",
|
||||||
frameNumber = frameNumber,
|
frameNumber = frameNumber,
|
||||||
})
|
})
|
||||||
else
|
|
||||||
print(string.format("[StateManager] WARNING: callSiteCounters has %d entries", callSiteCount))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -223,8 +223,16 @@ function FONT_CACHE.get(size, fontPath)
|
|||||||
local success, result = pcall(love.graphics.newFont, resolvedPath, size)
|
local success, result = pcall(love.graphics.newFont, resolvedPath, size)
|
||||||
if success then
|
if success then
|
||||||
font = result
|
font = result
|
||||||
|
else
|
||||||
|
-- Use ErrorHandler if available, otherwise fall back to print
|
||||||
|
if ErrorHandler then
|
||||||
|
ErrorHandler:warn("utils", "RES_004", {
|
||||||
|
resourceType = "font",
|
||||||
|
path = fontPath,
|
||||||
|
})
|
||||||
else
|
else
|
||||||
print("[FlexLove] Failed to load font: " .. fontPath .. " - using default font")
|
print("[FlexLove] Failed to load font: " .. fontPath .. " - using default font")
|
||||||
|
end
|
||||||
font = love.graphics.newFont(size)
|
font = love.graphics.newFont(size)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -462,8 +470,17 @@ local function safeLoadImage(imagePath)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
if not success then
|
if not success then
|
||||||
local errorMsg = string.format("[FlexLove] Failed to load image data: %s - %s", imagePath, tostring(imageData))
|
local errorMsg = string.format("Failed to load image data: %s - %s", imagePath, tostring(imageData))
|
||||||
print(errorMsg)
|
-- Use ErrorHandler if available, otherwise fall back to print
|
||||||
|
if ErrorHandler then
|
||||||
|
ErrorHandler:warn("utils", "RES_004", {
|
||||||
|
resourceType = "image data",
|
||||||
|
path = imagePath,
|
||||||
|
error = tostring(imageData),
|
||||||
|
})
|
||||||
|
else
|
||||||
|
print("[FlexLove] " .. errorMsg)
|
||||||
|
end
|
||||||
return nil, nil, errorMsg
|
return nil, nil, errorMsg
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -474,8 +491,17 @@ local function safeLoadImage(imagePath)
|
|||||||
if imageSuccess then
|
if imageSuccess then
|
||||||
return image, imageData, nil
|
return image, imageData, nil
|
||||||
else
|
else
|
||||||
local errorMsg = string.format("[FlexLove] Failed to create image: %s - %s", imagePath, tostring(image))
|
local errorMsg = string.format("Failed to create image: %s - %s", imagePath, tostring(image))
|
||||||
print(errorMsg)
|
-- Use ErrorHandler if available, otherwise fall back to print
|
||||||
|
if ErrorHandler then
|
||||||
|
ErrorHandler:warn("utils", "RES_004", {
|
||||||
|
resourceType = "image",
|
||||||
|
path = imagePath,
|
||||||
|
error = tostring(image),
|
||||||
|
})
|
||||||
|
else
|
||||||
|
print("[FlexLove] " .. errorMsg)
|
||||||
|
end
|
||||||
return nil, nil, errorMsg
|
return nil, nil, errorMsg
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user