code: def local_exception_handler(handler=None, coro=None):
      
      if handler is None:
          return lambda h: local_exception_handler(h, coro)
  
      if not hasattr(handler, "__call__"):
          raise TypeError("exception handlers must be callable")
  
      if coro is None:
          coro = compat.getcurrent()
  
      log.info("setting a new coroutine local exception handler")
  
      state.local_exception_handlers.setdefault(coro, []).append(
          weakref.ref(handler))
  
      return handler
docs: add a callback for when an exception occurs in a particular greenlet
  
      :param handler:
          the callback function, must be a function taking 3 arguments:
  
          - ``klass`` the exception class
          - ``exc`` the exception instance
          - ``tb`` the traceback object
      :type handler: function
      :param coro:
          the coroutine for which to apply the exception handler (defaults to the
          current coroutine)
      :type coro: greenlet