title: How to catch all exceptions in ruby?
body: <p>How can we catch or/and handle all unhandled exceptions in ruby?</p>
  
  <p>The motivation for this is maybe logging some kind of exceptions to different files or send and e-mail to the system administration, for example.</p>
  
  <p>In Java we will do</p>
  
  <pre><code>Thread.setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler ex);
  </code></pre>
  
  <p>In NodeJS</p>
  
  <pre><code>process.on('uncaughtException', function(error) {
     /*code*/
  });
  </code></pre>
  
  <p>In PHP</p>
  
  <pre><code>register_shutdown_function('errorHandler');
  
  function errorHandler() { 
      $error = error_get_last();
      /*code*/    
  }
  </code></pre>
  
  <p>How can we do this with ruby?</p>