Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Joose.Exception does currently not work!
I commited this only to demonstrate what options do not work. /* * What Joose.Exception should do: Provide a way to do JS Exception * - that use the standard try catch mechanism * - and (the hard part) that show a valid stack trace in firebug * - More info: http://joose-js.blogspot.com/2008/10/exceptions-in-javascript.html */ git-svn-id: http://joose-js.googlecode.com/svn/trunk@334 7be8dbaf-bf49-0410-bd10-bfef82906ff6
- Loading branch information
malte.ubl
committed
Nov 9, 2008
1 parent
b64cf8e
commit d0b423d
Showing
1 changed file
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// Joose.Exception does currently not work! | ||
// I commited this only to demonstrate what options do not work. | ||
|
||
/* | ||
* What Joose.Exception should do: Provide a way to do JS Exception | ||
* - that use the standard try catch mechanism | ||
* - and (the hard part) that show a valid stack trace in firebug | ||
* - More info: http://joose-js.blogspot.com/2008/10/exceptions-in-javascript.html | ||
*/ | ||
|
||
Class("Joose.Exception", { | ||
has: { | ||
message: {} | ||
}, | ||
methods: { | ||
initialize: function (message) { | ||
this.message = message | ||
}, | ||
|
||
toString: function () { | ||
return this.message | ||
} | ||
}, | ||
|
||
classMethods: { | ||
patchError: function () { | ||
Error.prototype.joosify = function () { | ||
if(this.joose) { | ||
return this.joose | ||
} | ||
var match; | ||
if(match = this.message.match(/^JOOSEERROR=(.+);(.*)/)) { | ||
var className = match[1]; | ||
var message = match[2]; | ||
var c = this.classNameToClassObject(className); | ||
this.joose = new c(this.message) | ||
return this.joose | ||
} | ||
throw new Error("Not a Joose Exception: "+this.message) | ||
} | ||
} | ||
} | ||
}) | ||
|
||
|
||
/*(function () { | ||
var ErrorBootstrap = function (message, filename, lineNumber) { | ||
this.message = message; | ||
if(filename) { | ||
this.filename = filename; | ||
} | ||
if(lineNumber) { | ||
this.lineNumber = lineNumber | ||
} | ||
var error = new Error(message, filename, lineNumber); | ||
this.stack = error.stack | ||
} | ||
ErrorBootstrap.prototype = new Error(); | ||
var toString = Error.prototype.toString; | ||
Joose.Exception = joosify("Joose.Exception", ErrorBootstrap); | ||
Joose.Exception.meta.addMethod("toString", toString); | ||
})()*/ | ||
|
||
/*Joose.Exception = function () { | ||
var f = function () {}; | ||
var c = Error; | ||
f.prototype = c.prototype; | ||
f.prototype.constructor = c; | ||
var obj = new f(); | ||
c.apply(obj, arguments); | ||
for(var i in obj) { | ||
this[i] = obj[i] | ||
console.log(""+i+" -> "+obj[i]) | ||
} | ||
}*/ | ||
|
||
//Joose.Exception.prototype = new Error() | ||
|
||
|
||
/*Class("Joose.Exception", { | ||
classMethods: { | ||
"throw": function (message) { | ||
var error = new Error(message) | ||
var ex = error; | ||
for(var i in error) { | ||
ex[i] = error[i] | ||
} | ||
if(ex.stack) { | ||
var stack = ex.stack.split("\n") | ||
var first = stack.shift() | ||
stack.shift() | ||
var parts = stack[0].split("@") | ||
var parts = parts[1].split(":") | ||
var lineNumber = parts.pop() | ||
var fileName = parts.join(":") | ||
ex.fileName = fileName | ||
ex.lineNumber = lineNumber | ||
ex.sourceLine = lineNumber | ||
ex.sourceName = fileName | ||
stack.unshift(first) | ||
ex.stack = stack.join("\n") | ||
//ex.category = "js" | ||
} | ||
throw ex | ||
} | ||
} | ||
})*/ |