Skip to content

Commit

Permalink
Fix missing stacks, remove duplicate info from stack, adjust source l…
Browse files Browse the repository at this point in the history
…ine determination
  • Loading branch information
brandonsturgeon committed Jan 23, 2024
1 parent 6457499 commit ec63eee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
3 changes: 2 additions & 1 deletion moon/cfc_err_forwarder/formatter/formatter.moon
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ nonil = (t) -> [v for v in *t when v ~= nil]

{
name: "Full Error"
value: code truncate client and data.fullError or niceStack data
value: code truncate niceStack data
}

with l = locals data
return { name: "Locals", value: code truncate(l), "m" } if l
return nil

with {:ply, :plyName, :plySteamID} = data
return { name: "Player", value: bold "#{plyName} ( #{steamIDLink plySteamID} )" } if ply
Expand Down
6 changes: 4 additions & 2 deletions moon/cfc_err_forwarder/formatter/nice_stack.moon
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
(data) ->
indent = 2
-- Start at -1 because we're going to increment before using it
indent = -1

lines = {data.fullError or "<unknown error>"}
lines = {}
stack = data.stack
return data.fullError unless stack and next stack

for i = 1, #stack do
indent = indent + 1
Expand Down
18 changes: 10 additions & 8 deletions moon/cfc_err_forwarder/plain_receiver.moon
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,17 @@ net.Receive "cfc_err_forwarder_clerror", (len, ply) ->
stackCount = math.min stackCount, 7

stack = {}
local sourceFile, sourceLine
for i = 1, stackCount
stack[i] =
source: net.ReadString!
name: net.ReadString!
currentline: net.ReadString!

firstLevel = stack[1]
sourceFile = firstLevel and firstLevel.source
sourceLine = firstLevel and firstLevel.currentline
source = net.ReadString!
name = net.ReadString!
currentline = net.ReadString!
stack[i] = { :source, :name, :currentline }

-- Always set it if it's not set, otherwise find the first non-[C] source
if sourceFile == nil or sourceFile == "[C]"
sourceFile = source
sourceLine = currentline

shouldForward = hook.Run "CFC_ErrorForwarder_OnReceiveCLError", ply, fullError, sourceFile, sourceLine, errorString, stack
return if shouldForward == false
Expand Down

0 comments on commit ec63eee

Please sign in to comment.