title: Wrap all methods of existing javascript object with try catch
body: <p>Is there a descent way to wrap all methods in an existing javascript object(for example third party library) with try catch so that I can process the exeception errors? Sure, I will expose the methods under a new interface. </p>
  
  <p>Here is what I have in mind for now:(consider it as pseudocode)</p>
  
  <pre><code>var MyInterface = {};
  for (var property in thirdPartyLib) {
    if ((typeof thirdPartyLib[property]) === 'function'){
      MyInterfac[property] = function(){
        try {
          thirdPartyLib[property](arguments)
        }
        catch(err){
           //do my custom processing
        }
      }
    }   
  }
  
  //developer use MyInterface object
  </code></pre>
  
  <p>Just wondering, any better approach or any flaw with my above idea? Thanks.</p>