Skip to content

Commit

Permalink
update(database): Call Stack
Browse files Browse the repository at this point in the history
  • Loading branch information
skuzzis committed Jan 11, 2025
1 parent 8638798 commit c1d0bb9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions plugin_files/bin/scripting/database.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ local json_decode = json.decode
AddEventHandler("OnDatabaseActionPerformed", function(event, databaseRequestID, result, err)
if not databaseRequestsQueue[databaseRequestID] then return EventResult.Continue end

local debuginfo = debug.getinfo(databaseRequestsQueue[databaseRequestID], "S")
local stackid = RegisterCallstack(GetCurrentPluginName(),
string.format("DatabaseCallback(path=%s,lines=%d..%d)", debuginfo.short_src, debuginfo.linedefined,
debuginfo.lastlinedefined))

local status, err = pcall(databaseRequestsQueue[databaseRequestID], err, json_decode(result) or {})
if not status then
print("An error has been occured while trying to execute a query.\nError: "..err)
print("An error has been occured while trying to execute a query.\nError: " .. err)
end

databaseRequestsQueue[databaseRequestID] = nil
UnregisterCallstack(GetCurrentPluginName(), stackid)

return EventResult.Stop
end)
end)

0 comments on commit c1d0bb9

Please sign in to comment.