Guest User

Untitled

a guest
Jun 20th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. var foo = {
  2. bar: function(x) {
  3. x.squeeze();
  4. }
  5. };
  6.  
  7. // this call will break your application :)
  8. // opps, TypeError: Object 42 has no method 'squeeze' :)
  9. foo.bar(42);
  10.  
  11. var errHandler = function(obj, meth, args, err) {
  12. alert(["error invoking method on object: ", obj, ", method: ", meth, ", ",args,", err : ", err].join(" "));
  13. }
  14.  
  15. contain(foo, errHandler);
  16.  
  17. // this call's errors will now be managed, oh snap
  18. foo.bar(42);
Add Comment
Please, Sign In to add comment