Created
June 12, 2024 18:26
-
-
Save ChecksumFailed/811cc14d5661346cc989680c1ced7664 to your computer and use it in GitHub Desktop.
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
/** | |
* Method to handle try/catch | |
* @param {Function} tryMethod - Method to try | |
* @param {Function} catchMethod - Method to call in case of error | |
* @param {Array} methodParams - Array of arguments to call with function.apply | |
* @private | |
* @returns Result of tryMethod or exception | |
*/ | |
_tryCatch: function (tryMethod, catchMethod) { | |
var context = this; | |
return function (methodParams) { | |
try { | |
return tryMethod.apply(context, methodParams); | |
} catch (ex) { | |
ex.caller = tryMethod.name || ''; | |
methodParams.unshift(ex); | |
catchMethod.apply(context, methodParams); | |
return ex; | |
} | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment