Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. functionName.before("try {")
  2.  
  3. functionName.after("} catch(ex){
  4. //dostuff
  5. }")
  6.  
  7. Function.prototype.wrapTry = function(handle) {
  8. var fn = this;
  9. return function() {
  10. try {
  11. return fn.apply(this, arguments);
  12. } catch(e) {
  13. return handle(e);
  14. }
  15. };
  16. };
  17.  
  18. var safeFunction = functionName.wrapTry(doStuff);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement