Created
October 31, 2014 03:16
-
-
Save acatl/d7dd716ea674cbf6b93d to your computer and use it in GitHub Desktop.
call try catch callback
This file contains hidden or 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
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