Created
June 1, 2015 11:11
-
-
Save MNBuyskih/2595b17f3861d70fd584 to your computer and use it in GitHub Desktop.
Quick error handling function
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 fail(errorCb, successCb, context) { | |
return function () { | |
var args = Array.prototype.slice.call(arguments), | |
isError = !!args[0]; | |
((isError ? errorCb : successCb) || function () { | |
return arguments; | |
}).apply(context || null, isError ? args : args.splice(1)); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
Predefined error handling