Thanks for the reply Wassenaar,
If I execute your script with slight modification , Trace does print the error message when an error is there.
set ErrorMode =0;
LOAD * FROM NoSuchTable;
LET vScriptError = 'Errorcode: ' & ScriptError;
Actually per Qlik Sense help , Script Error should return 0 if no error is there.
See this help section on Script Error ScriptError ‒ Qlik Sense
So when there are no errors, then if ScriptError=0 condition works. Problem was when I try to print the value in output. Tony Ventura from Qlik helped me out with this.
I was basically missing '#' in front of the variable. Below will print '0'
load * inline [ x,y
let vScriptError = ScriptError;
Trace vScriptError = $(#vScriptError);