mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
38 lines
No EOL
888 B
JavaScript
Executable file
38 lines
No EOL
888 B
JavaScript
Executable file
define([
|
|
],
|
|
|
|
function() {
|
|
|
|
function Exception(/* arguments */) {
|
|
var message = [];
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
var arg = arguments[i];
|
|
if (typeof arg == "object") {
|
|
var name = this.getTypeOfObject(arg);
|
|
message.push(name);
|
|
} else {
|
|
message.push(arg);
|
|
}
|
|
};
|
|
|
|
this.message = message.join(" ");
|
|
|
|
var e = Error.call(this, this.message);
|
|
console.log(e.stack)
|
|
}
|
|
|
|
Exception.prototype = Object.create(Error.prototype);
|
|
|
|
Exception.prototype.toString = function() {
|
|
return this.message;
|
|
};
|
|
|
|
Exception.prototype.getTypeOfObject = function (obj) {
|
|
var funcNameRegex = /function (.{1,})\(/;
|
|
var results = (funcNameRegex).exec((obj).constructor.toString());
|
|
return (results && results.length > 1) ? results[1] : "";
|
|
}
|
|
|
|
return Exception;
|
|
|
|
}); |