Help with debugging lua errors in console

I’m doing some code refactoring in gamemode and I get too much lua errors when trying to debug it. Maybe it’s not the right way to do this but for now I want to solve a problem with console lua errors. There are to many of them (as expected) and some of them occur in a loop, so the entire console is spammed with same errors. Is there a way to stop printing them to console? What I wanted to happen is to “killserver” when a lua error occurs but there’s no hook for it (“OnLuaError” works only in menu lua state). Do you have any ideas about it?

Try overriding this hook - that will be run clientside which killserver will work in (probably)

Ok, I tried to edit “errors.lua” and I figured out the way. If I call “RunConsoleCommand(“killserver”)” right in “OnLuaError” hook, the game crashes with an error “PhysCreateWorld_Shared: Map has no collision data! Possibly invalid map?”, obviously, because it’s not supposed to shutdown server like this. So I put “killserver” in a “timer” and it gave me a satisfactory result.

local _bAnyError = false

local function _fnKillServer()
    _bAnyError = false

hook.Add( "OnLuaError", "MenuErrorHandler", function(str, realm, addontitle, addonid)
    if (!_bAnyError) then
        timer.Create("tempdebug", 0, 1, _fnKillServer)
        _bAnyError = true
    ------ * * * ------