Handle error and failed eventSource events
@param   {Event} event The event object
@returns {void}
@private
333363
function handleFailedEvent(event) {
        var data = getData(event);
        viewerAPI.fire('realtimeerror', { error: data });
        realtime.destroy();
    }
23101
function handleUncaughtExceptions(error) {
  if (!error || !error.stack) {
    console.log('Uncaught exception:', error);
    process.exit();
  }
  var match = /\n    at [^(]+ \((.*):(\d+):(\d+)\)/.exec(error.stack);
  if (match) {
    var cache = {};
    var position = mapSourcePosition(cache, {
      source: match[1],
      line: match[2],
      column: match[3]
    });
    if (fs.existsSync(position.source)) {
      var contents = fs.readFileSync(position.source, 'utf8');
      var line = contents.split(/(?:\r\n|\r|\n)/)[position.line - 1];
      if (line) {
        console.log('\n' + position.source + ':' + position.line);
        console.log(line);
        console.log(new Array(+position.column).join(' ') + '^');
      }
    }
  }
  console.log(error.stack);
  process.exit();
}
508414
function handleError (task) {
  return function (err) {
    console.log(chalk.red(err));
    notify.onError(task + ' failed, check the logs..')(err);
  };
}
1213452
function(event){
        if (typeof event == "string"){
            event = { type: event };
        }
        if (!event.target){
            event.target = this;
        }

        if (!event.type){
            throw new Error("Event object missing 'type' property.");
        }

        if (this._handlers[event.type] instanceof Array){
            var handlers = this._handlers[event.type];
            for (var i=0, len=handlers.length; i < len; i++){
                handlers[i].call(this, event);
            }
        }
    }
162924
function(error) {
      this.errors.push(error);

      for (var i = 0, length = this.handlers.length; i < length; i++) {
        this.handlers[i](error);
      }
    }
248460
private void safePostEvent(Event event) {
        EventAdmin ea = eventAdminRef.getService();
        if (ea != null) {
            ea.postEvent(event);
        } else if (tc.isEventEnabled()) {
            Tr.event(tc, "The EventAdmin service is unavailable. Unable to post the Event: " + event);
        }
    }
696677
function on(eventNamesOrPatterns, handler) {
    if (!eventNamesOrPatterns) {
      throw new Error('Must pass at least one event name or matching RegEx');
    }
    assert.func(handler, 'handler');
    if (!Array.isArray(eventNamesOrPatterns)) {
      eventNamesOrPatterns = [eventNamesOrPatterns];
    }
    for (let i = 0; i < eventNamesOrPatterns.length; i++) {
      buckets.push({
        pattern: ensureRegExp(eventNamesOrPatterns[i]),
        handler: handler
      });
    }
  }
778504
function resolveScriptEvent(resolver, evt) {
        /*jshint validthis:true */
        var script = this;

        // run only when ready
        // script.readyState is completed or loaded
        if (script.readyState &&
            !(/^c|loade/.test(script.readyState))
        ) return;

        // never rerun callback
        if (script.loadStatus) return;

        // unbind to avoid rerun
        script.onload = script.onreadystatechange = script.onerror = null;

        script.loadStatus = true;

        if (evt && evt.type === "error") {
            var src = script.src || "Resource",
                fails = " fails to load.";

            // custom error
            // TODO: create a more specific stack for this Error
            var error = {
                name: "ConnectionError",
                source: src,
                evt: evt,
                stack: src + fails,
                message: fails,
                toString: function() {
                    return this.source + this.message;
                }
            };
            throwLater(error);

            resolver.reject(error);
            return;
        }

        resolver.resolve();
    }
150688
@MainThread
    private void handleEventResult(Event event, EventResult result) {
        if (!activeEvents.contains(event)) {
            Utils.logE(event.getKey(), "Cannot send result of finished event");
            return;
        }

        scheduleResultCallbacks(event, result);
        executeTasks(false);
    }
1256185
function _fixUIEvent(event) { // for issue 1168
	if (event.pageX === undefined) {
		event.pageX = event.originalEvent.pageX;
		event.pageY = event.originalEvent.pageY;
	}
}
1326525
function(event) {
            var target = event.target;
            if (this.checkElementByPattern(target)) {
                if (this.invalidElements.indexOf(target) > -1)
                    this.invalidElements.splice(this.invalidElements.indexOf(target), 1);
                this.publicInterface.onValidation([target]);
            } else {
                if (this.invalidElements.indexOf(target) === -1)
                    this.invalidElements.push(target);
                var legend = this.legends[this.currentValidationType] || this.legends.unknown;
                this.publicInterface.onInvalidation([target], legend);
            }
        }
915560
function(success, error, opts) {
    var event = new CustomEvent(opts[0], { detail: opts[1] } );
    if( document.dispatchEvent( event ) ) success({});
  }
1320906
function handleEvent(handler, day, modifiers) {
  if (!handler) {
    return undefined;
  }
  return function (e) {
    e.persist();
    handler(day, modifiers, e);
  };
}
1065409
public void dispatchEvent(IEvent event) {
        for (IEventListener listener : listeners) {
            if (event.getSource() == null || event.getSource() != listener) {
                listener.notifyEvent(event);
            }
        }
    }
1301255
function errorHandler (err) {
  let errorMessage = process.env.DEBUG ? err.stack : err.message;
  console.error(chalk.red(errorMessage));
  process.exit(1);
}
1344047
function handleMessages(event) {
  if (!isAllowed()) return;
  if (!event || event.source !== window || typeof event.data !== 'object') return;
  const message = event.data;
  if (message.source !== pageSource) return;
  if (message.type === 'DISCONNECT') {
    if (bg) {
      bg.disconnect();
      connected = false;
    }
    return;
  }

  tryCatch(send, message);
}
103577
function (sender, response) {
        //such boom, wow, very events.
        try {
            this.emit(sender, sender, response);
        }
        catch (ex) {
            logger.error("Error during response ", ex);
        }
    }