Skip to content

Instantly share code, notes, and snippets.

@acatl
Created October 31, 2014 03:16
Show Gist options
  • Save acatl/d7dd716ea674cbf6b93d to your computer and use it in GitHub Desktop.
Save acatl/d7dd716ea674cbf6b93d to your computer and use it in GitHub Desktop.
call try catch callback
function call(method) {
var args = Array.prototype.slice.call(arguments);
var callback = args.pop();
args = args.slice(1);
var error;
var result;
try {
result = method.apply(null, args);
} catch (e) {
error = e;
}
callback(error, result);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment