How to detect client side script error. ?

Started by habi, Nov 24, 2022, 12:58 PM

Previous topic - Next topic

habi

Just for the record, this is posted. In case someone in future needs this.

I had a client side script main.nut which was not working. Client side scripts not show errors in game.

If there is an error, download this program     sq.exe


Result

Note: You need to copy this sq.exe to your main.nut folder

Razor.

The error is also generated in debuglog.txt, or you can use a different error handler to display the error as local chat.

2b2ttianxiu

Quote from: habi on Nov 24, 2022, 12:58 PMJust for the record, this is posted. In case someone in future needs this.

I had a client side script main.nut which was not working. Client side scripts not show errors in game.

If there is an error, download this program     sq.exe


Result

Note: You need to copy this sq.exe to your main.nut folder


Set error handling, u can make error info to game console it. Find more: www.squirrel-lang.org

it's e.m
function errorHandling(err) {
local stackInfos = getstackinfos(2);
if (stackInfos) {
local locals = "";
foreach (index, value in stackInfos.locals) {
                locals = locals + "[" + index + ": " + type(value) + "] " + value + "\n";
        }
local callStacks = "";
local level = 2;
do {
callStacks += "*FUNCTION [" + stackInfos.func + "()] " + stackInfos.src + " line [" + stackInfos.line + "]\n";
level++;
} while ((stackInfos = getstackinfos(level)));
local errorMsg = "AN ERROR HAS OCCURRED [" + err + "]\n";
errorMsg += "\nCALLSTACK\n";
errorMsg += callStacks;
errorMsg += "\nLOCALS\n";
errorMsg += locals;
        foreach (i, msg in split(errorMsg, "\n")) print(msg)
        }
}
seterrorhandler(errorHandling);

Mohamed Boubekri

Quote from: habi on Nov 24, 2022, 12:58 PMdownload this program    sq.exe
Hey @habi, i have download it, and i have place it in store/script folder but when i run it, it says that i have some missing files like squirrel.dll, sqstdlib.dll, etc...
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

habi

hi Mohamed Boubekri,
i have updated it as zip file here. Unzip all of them.
Also add that location to PATH for easily accessing from command line.

Mohamed Boubekri

| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

Mohamed Boubekri

@habi, when i run my main.nut, the application told me that ( the index GUI dosen't exist )
Exactly that line:- ( sX <- GUI.GetScreenSize().X; ), but i'm sure the problem isn't here.
Actually i want something to catch all the errors on the client side like the original console on server side.
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

Mohamed Boubekri

Quote from: 2b2ttianxiu on Feb 01, 2023, 08:00 AMfunction errorHandling(err) {
 local stackInfos = getstackinfos(2);
 if (stackInfos) {
  local locals = "";
  foreach (index, value in stackInfos.locals) {
                locals = locals + "[" + index + ": " + type(value) + "] " + value + "\n";
        }
 local callStacks = "";
 local level = 2;
 do {
  callStacks += "*FUNCTION [" + stackInfos.func + "()] " + stackInfos.src + " line [" + stackInfos.line + "]\n";
  level++;
 } while ((stackInfos = getstackinfos(level)));
 local errorMsg = "AN ERROR HAS OCCURRED [" + err + "]\n";
 errorMsg += "\nCALLSTACK\n";
 errorMsg += callStacks;
 errorMsg += "\nLOCALS\n";
 errorMsg += locals;
        foreach (i, msg in split(errorMsg, "\n")) print(msg)
        }
}
seterrorhandler(errorHandling);[/quote]

Hey @2b2ttianxiu, how i can use that function ? i don't understand where do i will place it, or how i will mention it.
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

habi

That is client side code. Put it in store/script/main.nut

Then find
%APPDATA%\VCMPbeta\debuglog.txt
It might have result of those print statements.

2b2ttianxiu

Quote from: Mohamed Boubekri on Aug 14, 2023, 11:24 AM
Quote from: 2b2ttianxiu on Feb 01, 2023, 08:00 AMfunction errorHandling(err) {
 local stackInfos = getstackinfos(2);
 if (stackInfos) {
  local locals = "";
  foreach (index, value in stackInfos.locals) {
                locals = locals + "[" + index + ": " + type(value) + "] " + value + "\n";
        }
 local callStacks = "";
 local level = 2;
 do {
  callStacks += "*FUNCTION [" + stackInfos.func + "()] " + stackInfos.src + " line [" + stackInfos.line + "]\n";
  level++;
 } while ((stackInfos = getstackinfos(level)));
 local errorMsg = "AN ERROR HAS OCCURRED [" + err + "]\n";
 errorMsg += "\nCALLSTACK\n";
 errorMsg += callStacks;
 errorMsg += "\nLOCALS\n";
 errorMsg += locals;
        foreach (i, msg in split(errorMsg, "\n")) print(msg)
        }
}
seterrorhandler(errorHandling);[/quote]

Hey @2b2ttianxiu, how i can use that function ? i don't understand where do i will place it, or how i will mention it.

Put it in main script