QueryResponses.cs, DumpIndex.cs, IQueryResult.cs, QueryExecutor.cs, QueryResult.cs...
[beagle.git] / mozilla-extension / content / jslib / debug / debug.js
blob75f5f92567062d788f55e4df9fb9555e75157601
1 /*
3 The contents of this file are subject to the Mozilla Public
4 License Version 1.1 (the "License"); you may not use this file
5 except in compliance with the License. You may obtain a copy of
6 the License at http://www.mozilla.org/MPL/
8 Software distributed under the License is distributed on an "AS
9 IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
10 implied. See the License for the specific language governing
11 rights and limitations under the License.
13 The Original Code is jslib team code.
14 The Initial Developer of the Original Code is jslib team.
16 Portions created by jslib team are
17 Copyright (C) 2000 jslib team. All
18 Rights Reserved.
20 Original Author: Pete Collins <pete@mozdev.org>
21 Contributor(s):
22 Henrik Gemal <http://gemal.dk>
25 /************** DUBUG ******************/
26 if (typeof(JS_LIB_LOADED) == "boolean")
29 const JS_DEBUG_LOADED = true;
30 const JS_DEBUG_FILE = "debug.js";
32 /****************************************************************
33 * void jslibDebug(aOutString) *
34 * aOutString is an argument of string debug message *
35 * returns void *
36 * eg: *
37 * var msg="Testing function"; *
38 * jslibDebug(msg); *
39 * *
40 * outputs: Testing function *
41 ****************************************************************/
43 // DEPRECATED
44 function jslib_debug(aOutString) { return jslibDebug(aOutString); }
46 function jslibDebug(aOutString)
48 if (!JS_LIB_DEBUG)
49 return;
51 if (JS_LIB_DEBUG_ALERT)
52 alert(aOutString);
54 dump(aOutString+'\n');
57 // print to stdout
58 function jslibPrint(aOutString)
60 dump(aOutString+'\n');
63 // print to stdout
64 function jslibPrintDebug(aMsg, aOutString)
66 if (!aMsg) aMsg = "JSLIB_DEBUG: ";
67 dump(aMsg+aOutString+'\n');
70 // print to stdout
71 function jslibPrintBracket(aOutString)
73 dump("["+aOutString+']\n');
76 // print message
77 function jslibPrintMsg(aOutStr1, aOutStr2)
79 dump(aOutStr1+": "+aOutStr2+"\n");
83 /****************************************************************
84 * void jslibError(e, aType, aResults, aCaller) *
85 * e - argument of results exception *
86 * aType - argument of string error type message *
87 * aResults - argument of string Components.results name *
88 * aCaller - argument of string caller filename and func name *
89 * returns void *
90 * Ex: *
91 * jslibError(null, "Missing file path argument\n", *
92 * "NS_ERROR_XPC_NOT_ENOUGH_ARGS", *
93 * JS_LIB_FILE+": include"); *
94 * *
95 * outputs: *
96 * -----======[ ERROR ]=====----- *
97 * Error in jslib.js: include: Missing file path argument *
98 * *
99 * NS_ERROR_NUMBER: NS_ERROR_XPC_NOT_ENOUGH_ARGS *
100 * ------------------------------ *
102 ****************************************************************/
104 function jslibError(e)
106 var rv = null;
107 var errMsg="";
108 if (typeof(e) == 'object') {
109 var m, n, r, l, ln, fn = "";
110 try {
111 rv = e.result;
112 m = e.message;
113 fn = e.filename;
114 l = e.location;
115 ln = l.lineNumber;
116 } catch (e) {}
117 errMsg+="FileName: "+fn+"\n" +
118 "Result: "+rv+"\n" +
119 "Message: "+m+"\n" +
120 "LineNumber: "+ln+"\n";
123 errMsg = "\n-----======[ jsLib ERROR ]=====-----\n" + errMsg;
124 errMsg += "-------------------------------------\n";
126 jslibDebug(errMsg);
128 return rv;
131 function jslibErrorMsg (e)
133 jslibDebug(e);
134 return null;
137 function jslibErrorWarn (e)
139 jslibDebug("jsLib warn: "+e);
140 return null;
143 function jslibErrorMsg (e)
145 jslibDebug(e);
146 return jslibRes[e];
149 // Welcome message
150 jslibDebug('*** load: '+JS_DEBUG_FILE+' OK');
151 jslibDebug(JS_LIB_HELP);
152 jslibDebug("\n\n*********************\nJS_LIB DEBUG IS ON\n*********************\n\n");