title: Bottle middleware to catch exceptions of a certain type?
body: <p>Given this simple Bottle code:</p>
  
  <pre><code>def bar(i):
      if i%2 == 0:
          return i
      raise MyError
  
  @route('/foo')
  def foo():
      try:
          return bar()
      except MyError as e:
          response.status_code = e.pop('status_code')
          return e
  </code></pre>
  
  <p>How would one write Bottle middleware so the same exception handling is done implicitly, so that code like this can work identically to above:</p>
  
  <pre><code>@route('/foo')
  def foo():
      return bar()
  </code></pre>