Improve output: distinguish between failed assertions (failures) and unexpected exceptions (errors), and print a filtered stack trace for any exception.
This commit is contained in:
commit
4f2e303079
1839 changed files with 235630 additions and 0 deletions
80
webapp/web/src/debug.js
Normal file
80
webapp/web/src/debug.js
Normal file
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
Copyright (c) 2004-2006, The Dojo Foundation
|
||||
All Rights Reserved.
|
||||
|
||||
Licensed under the Academic Free License version 2.1 or above OR the
|
||||
modified BSD license. For more information on Dojo licensing, see:
|
||||
|
||||
http://dojotoolkit.org/community/licensing.shtml
|
||||
*/
|
||||
|
||||
/**
|
||||
* Produce a line of debug output.
|
||||
* Does nothing unless djConfig.isDebug is true.
|
||||
* varargs, joined with ''.
|
||||
* Caller should not supply a trailing "\n".
|
||||
*/
|
||||
dojo.debug = function(){
|
||||
if (!djConfig.isDebug) { return; }
|
||||
var args = arguments;
|
||||
if(dj_undef("println", dojo.hostenv)){
|
||||
dojo.raise("dojo.debug not available (yet?)");
|
||||
}
|
||||
var isJUM = dj_global["jum"] && !dj_global["jum"].isBrowser;
|
||||
var s = [(isJUM ? "": "DEBUG: ")];
|
||||
for(var i=0;i<args.length;++i){
|
||||
if(!false && args[i] && args[i] instanceof Error){
|
||||
var msg = "[" + args[i].name + ": " + dojo.errorToString(args[i]) +
|
||||
(args[i].fileName ? ", file: " + args[i].fileName : "") +
|
||||
(args[i].lineNumber ? ", line: " + args[i].lineNumber : "") + "]";
|
||||
} else {
|
||||
try {
|
||||
var msg = String(args[i]);
|
||||
} catch(e) {
|
||||
if(dojo.render.html.ie) {
|
||||
var msg = "[ActiveXObject]";
|
||||
} else {
|
||||
var msg = "[unknown]";
|
||||
}
|
||||
}
|
||||
}
|
||||
s.push(msg);
|
||||
}
|
||||
if(isJUM){ // this seems to be the only way to get JUM to "play nice"
|
||||
jum.debug(s.join(" "));
|
||||
}else{
|
||||
dojo.hostenv.println(s.join(" "));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* this is really hacky for now - just
|
||||
* display the properties of the object
|
||||
**/
|
||||
|
||||
dojo.debugShallow = function(obj){
|
||||
if (!djConfig.isDebug) { return; }
|
||||
dojo.debug('------------------------------------------------------------');
|
||||
dojo.debug('Object: '+obj);
|
||||
var props = [];
|
||||
for(var prop in obj){
|
||||
try {
|
||||
props.push(prop + ': ' + obj[prop]);
|
||||
} catch(E) {
|
||||
props.push(prop + ': ERROR - ' + E.message);
|
||||
}
|
||||
}
|
||||
props.sort();
|
||||
for(var i = 0; i < props.length; i++) {
|
||||
dojo.debug(props[i]);
|
||||
}
|
||||
dojo.debug('------------------------------------------------------------');
|
||||
}
|
||||
|
||||
dojo.debugDeep = function(obj){
|
||||
if (!djConfig.isDebug) { return; }
|
||||
if (!dojo.uri || !dojo.uri.dojoUri){ return dojo.debug("You'll need to load dojo.uri.* for deep debugging - sorry!"); }
|
||||
if (!window.open){ return dojo.debug('Deep debugging is only supported in host environments with window.open'); }
|
||||
var win = window.open(dojo.uri.dojoUri("src/debug/deep.html"), '_blank', 'width=600, height=400, resizable=yes, scrollbars=yes, status=yes');
|
||||
win.debugVar = obj;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue