Add a callback, wrapped in a try/catch so as to not break the
execution of Oboe if an exception is thrown (fail events are
fired instead)

The callback is used as the listener id so that it can later be
removed using .un(callback)
334402
function addProtectedCallback(eventName, callback) {
    oboeBus(eventName).on(protectedCallback(callback), callback);
    return oboeApi; // chaining
  }
218922
function _callHandler(handler) {
        try {
            // TODO (issue 1034): We *could* use a $.Deferred for this, except deferred objects enter a broken
            // state if any resolution callback throws an exception. Since third parties (e.g. extensions) may
            // add callbacks to this, we need to be robust to exceptions
            handler();
        } catch (e) {
            console.error("Exception when calling a 'brackets done loading' handler: " + e);
            console.log(e.stack);
        }
    }
312968
def add_listener(self, listener):
        
        self.logger.debug('installing listener %r', listener)
        if not isinstance(listener, SessionListener):
            raise SessionError("Listener must be a SessionListener type")
        with self._lock:
            self._listeners.add(listener)
1203684
public S onFailure(CheckedConsumer<? extends ExecutionCompletedEvent<R>> listener) {
    failureListener = EventListener.of(Assert.notNull(listener, "listener"));
    return (S) this;
  }
10780
public void notifyFailure(final Callback<?> callback, final Throwable error) {
    invokeLater(new Runnable() {
      public void run() {
        callback.onFailure(error);
      }
    });
  }
272053
public void addListener(IsSimplePromiseResponseHandler<T> listener) {
    if (handlers == null) {
      handlers = new LinkedList<>();
    }

    handlers.add(listener);

    if (response != null || exception != null) {
      listener.onResponse(this);
    }
  }
108454
def on(self, name, callback, once=False):
        
        if name not in self.event_listeners:
            self.event_listeners[name] = []

        self.event_listeners[name].append((callback, once))
622534
private static void invokeCallbackMethod(Method callbackMethod, Object listener, Object entity) {
    try {
      callbackMethod.invoke(listener, entity);
    } catch (Exception exp) {
      String message = String.format("Failed to execute callback method %s of class %s",
          callbackMethod.getName(), callbackMethod.getDeclaringClass().getName());
      throw new EntityManagerException(message, exp);
    }

  }
1119734
def add_listener(self, evt_name, fn):
        
        self._listeners.setdefault(evt_name, [])
        listeners = self.__get_listeners(evt_name)
        listeners.append(fn)
615811
def __callback(self, data):
        
        method = self.__cb_message
        if method is not None:
            try:
                method(data)
            except Exception as ex:
                _logger.exception("Error calling method: %s", ex)
1119329
function (callback, trace) {
      return function (arg) {
        try {
          callback(arg);
        } catch (error) {
          if (this.listenerCount('error')) {
            this.emit('error', error, trace);
          } else {
            console.error(error, trace);
          }
        }
      }.bind(this);
    }
328848
def run_listener(listener)
      retry_count = 0

      begin
        listener.start
      rescue Exception => e
        handle_crashed_listener(listener, e, retry_count)
        retry_count += 1
        retry unless @signal_to_stop
      end
    rescue Exception => e
      log_error("Failed to run listener (#{e.message})", error_metadata(e))
      raise e
    end
749871
public final synchronized void addListener(EventListener l) {
        if(l ==null) {
            throw new IllegalArgumentException("Listener " + l +
                                               " is null");
        }
        if(listeners == EMPTY_LISTENERS) {
            listeners = new EventListener[1];
            listeners[0] = l;
        }
        else {
            int i = listeners.length;
            EventListener[] tmp = new EventListener[i+1];
            System.arraycopy(listeners, 0, tmp, 0, i);

            tmp[i] = l;
            listeners = tmp;
        }
    }
241399
function addListener(event, callback, meta) {
  event.listeners.push(callback);
  event.meta.set(callback, meta);
}
874563
def add_callbacks(self, future, callback, errback):
        
        def done(f):
            try:
                res = f.result()
                if callback:
                    callback(res)
            except Exception:
                if errback:
                    errback(create_failure())
        return future.add_done_callback(done)
1156891
function on(eventName, callback) {
  	if (objectType(eventName) !== "string") {
  		throw new TypeError("eventName must be a string when registering a listener");
  	} else if (!inArray(eventName, SUPPORTED_EVENTS)) {
  		var events = SUPPORTED_EVENTS.join(", ");
  		throw new Error("\"" + eventName + "\" is not a valid event; must be one of: " + events + ".");
  	} else if (objectType(callback) !== "function") {
  		throw new TypeError("callback must be a function when registering a listener");
  	}

  	if (!LISTENERS[eventName]) {
  		LISTENERS[eventName] = [];
  	}

  	// Don't register the same callback more than once
  	if (!inArray(callback, LISTENERS[eventName])) {
  		LISTENERS[eventName].push(callback);
  	}
  }
639590
public void addListener(final WebAppListener listener) {
		NullArgumentException.validateNotNull(listener, "Listener");
		NullArgumentException.validateNotNull(listener.getListenerClass(),
				"Listener class");
		if (!listeners.contains(listener)) {
			listeners.add(listener);
		}
	}