Hi!
Is there a way I can get debugging info, such as line and column, about a caught exception?
If it's left uncaught, DOpus tells me the info in output, but on first sight, the object that it provides to the catch
block doesn't seem to contain any:
// ...
// ...
function OnClick(data)
{
try{
a = b + c;
}
catch(e){
log(e);
}
a = b + c;
}
function log(obj) {
obj = stringify(obj) + "";
var l = obj.length;
var c = l;
var maxLen = 65520;
while(c>maxLen){
DOpus.Output(obj.substr(l-c, maxLen));
c -= maxLen;
}
DOpus.Output(obj.substr(l-c));
}
function msg(s, buttons) {
if(typeof(buttons) == "undefined")
buttons = "OK";
var dlg = DOpus.Dlg;
var arr = buttons.split("|");
if(arr.length>1){
var defid = 1;
for(var i = 0; i<arr.length; i++){
var b = arr[i];
if(b.substr(0,1)=="+"){
defid = i+1;
arr[i] = b.substr(1);
}
}
dlg.defid = defid;
buttons = arr.join("|");
}
s = stringify(s);
log("MSG: " + s);
dlg.message = s;
dlg.buttons = buttons;
dlg.icon = "info";
return dlg.show();
}
function stringify(obj) {
if(typeof obj == "undefined")
obj = "[undefined]";
else if(obj === null)
obj = "[null]";
else if(typeof obj == "object"){
var o = obj;
obj = "[Object " + DOpus.TypeOf(obj) + "]\n";
obj += dump(o);
} else if(obj === false)
obj = "FALSE";
else if(obj === true)
obj = "TRUE";
else if(obj==="")
obj = "[empty]";
return obj;
}
function dump(arr, level){
var dumped_text = "";
if(!level) level = 0;
var bs = "\n";
var level_padding = "";
for(var j = 0; j < level + 1; j++) level_padding += " ";
if(typeof (arr) == 'object'){ //Array/Hashes/Objects
for(var item in arr){
var value = arr[item];
if(typeof (value) == 'object'){
dumped_text += level_padding + "'" + item + "' (" + DOpus.TypeOf(value) + "){" + bs;
dumped_text += dump(value, level + 1) + bs + "}";
}else{
if(typeof(value.toString)=="function")
value = value.toString();
var m = value.match(/function\s*\(([^\)]*)\)\s*\{/i);
if(m)
value = "function(" + m[1] + ")";
dumped_text += level_padding + "'" + item + "' => \"" + value + "\"" + bs;
}
}
} else { //Stings/Chars/Numbers etc.
dumped_text = "===>" + arr + "<===(" + typeof (arr) + ")";
}
return dumped_text;
}```