Skip to content

Instantly share code, notes, and snippets.

@mc0

mc0/exception.js Secret

Created August 12, 2009 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mc0/1bf764be412d5c956086 to your computer and use it in GitHub Desktop.
Save mc0/1bf764be412d5c956086 to your computer and use it in GitHub Desktop.
/*------------------------------ LANG: EXCEPTION ---------------------------*/
Fuse.addNS('Exception', {
'constructor': function(error, info) {
if (Fuse.debug) {
if (typeof error != 'undefined')
Fuse.Exception.console.error(error);
if (typeof info != 'undefined')
Fuse.Exception.console.info(info);
}
}
});
(function(Exception) {
var defaultConsole = {
error: function error(error) { throw error },
info: Fuse.emptyFunction
};
if (isHostObject(global, 'console') &&
isHostObject(global.console, 'info') &&
isHostObject(global.console, 'error'))
Exception.console = global.console;
else if (isHostObject(global, 'opera') &&
isHostObject(global.opera, 'postError'))
Exception.console = {
error: function error(error) { global.opera.postError(error); },
info: function info(info) { global.opera.postError(info); }
};
else if (isHostObject(global, 'Jaxer')) {
var j = global.Jaxer;
if (isHostObject(j, 'Log') &&
isHostObject(j.Log, 'info') &&
isHostObject(j.Log, 'error'))
Exception.console = {
error: function error(error) { j.Log.error("FuseJS: " + +new Date, error) },
info: function info(info) { j.Log.info("FuseJS: " + +new Date, info) }
};
else Exception.console = defaultConsole;
}
else Exception.console = defaultConsole;
// prevent JScript bug with named function expressions
var error = null,
info = null;
})(Fuse.Exception);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment