- Throw Error objects instead of Strings.

This commit is contained in:
Paulo Gustavo Veiga 2012-09-19 20:01:22 -03:00
parent 6555203a94
commit cd776073dc
5 changed files with 316 additions and 314 deletions

View File

@ -15,7 +15,7 @@ $assert = function (assert, message) {
if (!$defined(assert) || !assert) {
var stack;
try {
null.eval();
throw Error("Unexpected Exception");
} catch (e) {
stack = e;
}
@ -33,7 +33,7 @@ function stackTrace(exception) {
if (!$defined(exception)) {
try {
throw "Dummy Exception"
throw Error("Unexpected Exception");
} catch (e) {
exception = e;
}
@ -45,6 +45,8 @@ function stackTrace(exception) {
else if (window.opera && exception.message) { //Opera
result = exception.message;
} else { //IE and Safari
result = exception.sourceURL + ': ' + exception.line + "\n\n";
var currentFunction = arguments.callee.caller;
while (currentFunction) {
var fn = currentFunction.toString();

View File

@ -80,7 +80,7 @@ mindplot.IconGroup = new Class({
}, this);
if (result == null) {
throw "Icon can no be found.";
throw new Error("Icon can no be found:" + iconModel);
}
return result;

View File

@ -47,7 +47,7 @@ mindplot.LocalStorageManager = new Class({
// If I could not load it from a file, hard code one.
if (xml == null) {
throw "Map could not be loaded";
throw new Error("Map could not be loaded");
}
}

View File

@ -20,7 +20,7 @@ web2d.Element = new Class({
initialize : function(peer, attributes) {
this._peer = peer;
if (peer == null) {
throw "Element peer can not be null";
throw new Error("Element peer can not be null");
}
if ($defined(attributes)) {
@ -53,7 +53,7 @@ web2d.Element = new Class({
for (var key in batchExecute) {
var func = this[key];
if (!$defined(func)) {
throw "Could not find function: " + key;
throw new Error("Could not find function: " + key);
}
func.apply(this, batchExecute[key]);
}
@ -114,7 +114,7 @@ web2d.Element = new Class({
* Returns element type name.
*/
getType : function() {
throw "Not implemeneted yet. This method must be implemented by all the inherited objects.";
throw new Error("Not implemeneted yet. This method must be implemented by all the inherited objects.");
},
/**
@ -146,7 +146,7 @@ web2d.Element = new Class({
*/
setStroke : function(width, style, color, opacity) {
if (style != null && style != undefined && style != 'dash' && style != 'dot' && style != 'solid' && style != 'longdash' && style != "dashdot") {
throw "Unsupported stroke style: '" + style + "'";
throw new Error("Unsupported stroke style: '" + style + "'");
}
this._peer.setStroke(width, style, color, opacity);
},

View File

@ -46,7 +46,7 @@ function buildDesigner(options) {
emulation:false,
urlEncoded:false
}).post(JSON.encode({
jsErrorMsg:"message: " + message + ", line:" + lineNo + ", :" + url,
jsErrorMsg:"message: '" + message + "', line:'" + lineNo + "', :" + url,
jsStack:window.errorStack,
userAgent:navigator.userAgent,
mapId:options.mapId}));