       callback
     )
 
+  # Public: Adds an error handler when an uncaught exception or user emitted
+  # error event occurs.
+  #
+  # callback - A Function that is called with the error object.
+  #
+  # Returns nothing.
+  error: (callback) ->
+    @errorHandlers.push callback
+
+  # Calls and passes any registered error handlers for unhandled exceptions or
+  # user emitted error events.
+  #
+  # err - An Error object.
+  #
+  # Returns nothing.
+  invokeErrorHandlers: (err) ->
+    errorHandler err for errorHandler in @errorHandlers
+
   # Public: Adds a Listener that triggers when no other text matchers match.
   #
   # callback - A Function that is called with a Response object.

        results.push listener.call(message)
        break if message.done
      catch error
        @logger.error "Unable to call the listener: #{error}\n#{error.stack}"
        false
    if message not instanceof CatchAllMessage and results.indexOf(true) is -1

    else
      @setupNullRouter()
    @pingIntervalId = null

    @loadAdapter adapterPath, adapter

    @errorHandlers = []

    @on 'error', @invokeErrorHandlers
    process.on 'uncaughtException', (err) =>
      @invokeErrorhandlers(err)


  # Public: Adds a Listener that attempts to match incoming messages based on
  # a Regex.
