mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
added Exception handling and added applyCommands
This commit is contained in:
parent
7977220404
commit
b82a027f4f
2 changed files with 59 additions and 16 deletions
37
app/Lib/Utilities/Exception.js
Normal file
37
app/Lib/Utilities/Exception.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
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(" ");
|
||||
|
||||
Error.call(this, this.message);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue