// Registers that the handler has completed with an error
544712
func (h *AsyncHttpHandler) CompletedWithError(err error) {

	h.manager.lock.RLock()
	defer h.manager.lock.RUnlock()

	godbc.Require(h.completed == false)

	h.err = err
	h.completed = true

	godbc.Ensure(h.completed == true)
}
802451
func (ed *Dispatcher) RegisterHandler(t interface{}, h Handler) {
	htype := reflect.TypeOf(t)
	if _, ok := ed.handlers[htype]; !ok {
		logger.Debugf("Registering handler for %s on dispatcher %T", htype, ed)
		ed.handlers[htype] = h
	} else {
		logger.Debugf("Cannot register handler %s on dispatcher %T since it's already registered", htype, ed)
	}
}
1070355
func (d *Dispatcher) Register(etype Type, callback Callback) {
	if callback == nil {
		return
	}

	d.Lock()
	defer d.Unlock()
	d.callbacks[etype] = append(d.callbacks[etype], callback)
}
1313043
func Errors() HandlerFunc {
	return func(ctx *Context) {
		switch res := ctx.Result.(type) {
		case AbortError:
			ctx.WriteHeader(res.Code())
			ctx.WriteString(res.Error())
		case error:
			ctx.WriteHeader(http.StatusInternalServerError)
			ctx.WriteString(res.Error())
		default:
			ctx.WriteHeader(http.StatusInternalServerError)
			ctx.WriteString(http.StatusText(http.StatusInternalServerError))
		}
	}
}
421114
func (ovs *OvsdbClient) Register(handler NotificationHandler) {
	ovs.handlersMutex.Lock()
	defer ovs.handlersMutex.Unlock()
	ovs.handlers = append(ovs.handlers, handler)
}
1032723
func (s *Server) Register(api API) {
	uri := api.URI()
	if len(uri) == 0 {
		panic("URI() return empty string")
	}
	if uri[0] != '/' {
		uri = "/" + uri
	}
	log.Infof("New api handler, uri=%s", uri)

	// raw http handler
	if handler, ok := api.(http.Handler); ok {
		s.Get("/v2"+uri, handler.ServeHTTP)
		return
	}
	s.Get(
		"/v2"+uri,
		func(w http.ResponseWriter, r *http.Request, es *EventSource, ctx context.Context) {
			if GetBool(r, "watch", false) {
				handleWatch(api, w, r, es, ctx)
			} else {
				handleGet(api, w, r, ctx)
			}
		},
	)
}
457846
func (h *Handler) Handle(err error) {
	// Get HTTP request (if any)
	req, _ := httperr.HTTPRequest(err)

	notice := h.notifier.Notice(emperror.ExposeStackTrace(err), req, 1)

	// Extract context from the error and attach it to the notice
	notice.Params = keyvals.ToMap(emperror.Context(err))

	if h.sendSynchronously {
		_, _ = h.notifier.SendNotice(notice)
	} else {
		h.notifier.SendNoticeAsync(notice)
	}
}
320463
func (ed *Dispatcher) RegisterHandlers() {
	ed.RegisterHandler(&RegisterChaincodeEvent{}, ed.handleRegisterCCEvent)
	ed.RegisterHandler(&RegisterTxStatusEvent{}, ed.handleRegisterTxStatusEvent)
	ed.RegisterHandler(&RegisterBlockEvent{}, ed.handleRegisterBlockEvent)
	ed.RegisterHandler(&RegisterFilteredBlockEvent{}, ed.handleRegisterFilteredBlockEvent)
	ed.RegisterHandler(&UnregisterEvent{}, ed.handleUnregisterEvent)
	ed.RegisterHandler(&StopEvent{}, ed.HandleStopEvent)
	ed.RegisterHandler(&TransferEvent{}, ed.HandleTransferEvent)
	ed.RegisterHandler(&StopAndTransferEvent{}, ed.HandleStopAndTransferEvent)
	ed.RegisterHandler(&RegistrationInfoEvent{}, ed.handleRegistrationInfoEvent)

	// The following events are used for testing only
	ed.RegisterHandler(&fab.BlockEvent{}, ed.handleBlockEvent)
	ed.RegisterHandler(&fab.FilteredBlockEvent{}, ed.handleFilteredBlockEvent)
}
894428
func (k *Kite) OnRegister(handler func(*protocol.RegisterResult)) {
	k.handlersMu.Lock()
	k.onRegisterHandlers = append(k.onRegisterHandlers, handler)
	k.handlersMu.Unlock()
}
432339
func DefaultErrorHandler(w http.ResponseWriter, r *http.Request, err error) {
	panic(err)
}
852646
func (h *handler) Close() error {
	h.once.Do(func() { close(h.c) })
	return nil
}
1290469
func register(ch *tchannel.Channel) error {
	ch.Register(raw.Wrap(echoRawHandler{}), "echo/raw")
	ch.Register(raw.Wrap(handlerTimeoutRawHandler{}), "handlertimeout/raw")

	if err := json.Register(ch, json.Handlers{"echo": echoJSONHandler}, onError); err != nil {
		return err
	}

	tserver := thrift.NewServer(ch)
	tserver.Register(echo.NewTChanEchoServer(&echoThriftHandler{}))
	tserver.Register(gauntlet_tchannel.NewTChanThriftTestServer(&thriftTestHandler{}))
	tserver.Register(gauntlet_tchannel.NewTChanSecondServiceServer(&secondServiceHandler{}))
	return nil
}
190920
func (ref *AsyncProducer) errorHandler(in <-chan *sarama.ProducerError) {
	ref.Debug("starting error handler ...")
	for {
		select {
		case <-ref.closeChannel:
			ref.Debug("error handler exited ...")
			return
		case perr := <-in:
			if perr == nil {
				continue
			}

			msg := perr.Msg
			err := perr.Err
			pmsg := &ProducerMessage{
				Topic:     msg.Topic,
				Key:       msg.Key,
				Value:     msg.Value,
				Metadata:  msg.Metadata,
				Offset:    msg.Offset,
				Partition: msg.Partition,
			}
			perr2 := &ProducerError{
				ProducerMessage: pmsg,
				Err:             err,
			}
			val, _ := msg.Value.Encode()
			ref.Errorf("message %s errored in topic(%s)/partition(%d)/offset(%d)\n", string(val), pmsg.Topic, pmsg.Partition, pmsg.Offset)
			ref.Errorf("message error: %v", perr.Err)
			ref.Config.ErrorChan <- perr2
		}
	}
}
1246167
func (eng *Engine) Register(handler Handler) {
	if eng.Handler == Discard {
		eng.Handler = handler
	} else {
		eng.Handler = MultiHandler(eng.Handler, handler)
	}
}
181941
func (d *Dispatcher) handler(payload proto.Message) (handler, error) {
	name := proto.MessageName(payload)

	d.mu.RLock()
	defer d.mu.RUnlock()

	handler, registered := d.handlers[name]
	if !registered {
		return handler, fmt.Errorf("handler for %q is not registered", name)
	}
	return handler, nil
}
677003
func RegisterError(name string, num int) {
	nm := strings.ToUpper(name)
	AllErrors[nm] = num
	AllErrorNumbers[num] = nm
	RegisterConstant(nm, num)
}
348893
func (self *SocketHandler) HandleError(record *LogRecord, err error) {
	if self.closeOnError && (self.conn != nil) {
		self.conn.Close()
		self.conn = nil
	} else {
		self.BaseHandler.HandleError(record, err)
	}
}