CFC-Servers / cfc_err_forwarder

Send both server and client Gmod errors to your Discord channel
20 stars 1 forks source link

CFC Error Forwarder

A pure-lua (well, Moonscript) Error tracker for Garry's Mod.

This addon will watch for errors, do a little investigation, and send a message to a Discord channel for your review.

Who is this for?

This is for Server Owners/Operators. This allows server operators to monitor and manage the errors that occur on their server.

Who is this not for?

Addon developers looking for a way to track their errors automatically across all servers - this is not the tool for you.


Notice ⚠️

A full-rewrite of this addon is nearly complete. It has fixes, new features, design reworks, discord ratelimit prevention, reliability improvements, and more.

Please keep an eye out for the update!

You can track its progress (or ask questions) in our support Discord: https://discord.gg/5JUqZjzmYJ


Some nifty features:

Requirements

Installation

Simple

Source Controlled

Configuration

Screenshots

Serverside Error with Locals and Context

DiscordCanary_nmbYDY33PH

Clientside Error with Context

image


Hooks

CFC_ErrorForwarder_PreQueue

Called before an Error is queued to be processed.

Return false to prevent it from being queued.

You may also (carefully) modify the error structure.

Error Structure

With the following code:

-- addons/example/lua/example/init.lua
AddCSLuaFile()
if SERVER then return end

local function exampleFunction()
    print( 5 + {} )
end

hook.Add( "InitPostEntity", "Example", function()
    ProtectedCall( exampleFunction )
end )
The error structure would look like: Name Type Example Description
branch string "unknown" (Base branch) The game branch where the error occurred. Is either "Not sure yet" if the client errored early, or BRANCH string
count number 1 How many times this error has occurred _(Will always be 1 in CFC_ErrorForrwarder_PreQueue)_
errorString string "attempt to perform arithmetic on a table value" The actual error message that was produced
fullError string The full, raw, multiline error string with a simplified stack
isClientside boolean true Whether or not this error occurred on a client
isRuntime boolean true "Whether this is a runtime error or not" - taken straight from gm_luaerror
occurredAt number 1704534832 The result of os.time() of when the error occurred
ply Player Player [1][Phatso] The Player who experienced the error, or nil if serverside
plyName string "Phatso" nil if serverside
plySteamID string "STEAM_0:0:21170873" nil if serverside
reportInterval number 60 In seconds, how often the addon is sending errors to Discord
sourceFile string "addons/test/lua/example/init.lua" The file path where the error occurred
sourceLine number 4 The line in the file where the error occurred
stack table { 1 = { currentline = 4, name = "unknown", source = "..." }, ... } A numerically indexed Stack object


CFC_ErrorForwarder_OnReceiveCLError

This hook is only called when the luaerror dll is not installed.

This hook is called in the network receiver that is triggered when a player forwards their error to the server.

Return false to prevent it from being processed.