// errorHandler handles error messages
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
		}
	}
}
676285
func RebalancerErrorHandler(h utils.ErrorHandler) RebalancerOption {
	return func(r *Rebalancer) error {
		r.errHandler = h
		return nil
	}
}
1247290
func (c *ChannelLogger) ErrorLogger(err error) Logger {
	c.Err <- err
	return c
}
1209735
func (t *Tango) UseHandler(handler http.Handler) {
	t.Use(WrapBefore(handler))
}
644741
func RecoveryHandler(handler func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request) {
	return Recoverer(http.HandlerFunc(handler)).ServeHTTP
}
95335
func MessageHandler(Incoming <-chan tgbot.MessageWithUpdateID, bot *tgbot.TgBot) {
	for {
		input := <-Incoming

		if input.Msg.Text != nil {
			text := handleMessageText(*input.Msg.Text, input.Msg)
			if text != "" {
				nmsg, err := bot.SimpleSendMessage(input.Msg, text)
				if err != nil {
					fmt.Println(err)
					continue
				}
				fmt.Println(nmsg.String())
			}
		}
	}
}
903045
func (l *Logger) SetErrorHandler(h func(error) error) {
	l.errorHandler.Store(h)
}
1007843
func MakeErrorHandler(hfcn http.HandlerFunc) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		// catch errors
		defer func() {
			if err, ok := recover().(error); ok {
				w.WriteHeader(http.StatusInternalServerError)
				fmt.Fprintf(w, "INTERNAL ERROR (dmp): 500 HTTP error:\n%v", err)
			}
		}()
		// call the wrapped handler
		hfcn(w, r)
	}
}
421534
func (app *Application) handleError(ctx *Context, statusCode int, data ...map[string]interface{}) {
	ctx.SendStatus(statusCode)
	handler, ok := app.errorHandler[statusCode]
	if !ok {
		defaultErrorHandler(ctx, data...)
		return
	}
	handler(ctx)
}
1312245
func (c *Client) UseHandler(phase string, fn context.HandlerFunc) *Client {
	c.Middleware.UseHandler(phase, fn)
	return c
}
1007428
func (c *Conn) CloseHandler() func(code int, text string) error {
	return c.handleClose
}
54958
func HandlerErrorLogger(logger log.Logger) HandlerOption {
	return func(h *Handler) { h.errorHandler = transport.NewLogErrorHandler(logger) }
}
648938
func (err HandlerError) Error() string {
	return fmt.Sprintf("%s in:\n%s", err.Err.Error(), err.Stack)
}
362608
func (r *Router) handleError(c *Context, err error) {
	if httpError, ok := err.(HTTPError); ok {
		c.Error(httpError.Error(), httpError.StatusCode())
	} else {
		c.Error(err.Error(), http.StatusInternalServerError)
	}
}
540688
func (r *Router) HTTPSHandler(handler http.Handler, config *tls.Config) {
	r.httpsHandler = handler
	r.httpsTLSConfig = config
}
1001407
func goErrorHandler(code C.int, reason *C.char) {
	reasonHeader := reflect.StringHeader{
		Data: uintptr(unsafe.Pointer(reason)),
		Len:  int(C.strlen(reason)),
	}
	reasonString := (*string)(unsafe.Pointer(&reasonHeader))
	Log.Printf("%s -- %s", codeToString(int(code)), *reasonString)
}
432339
func DefaultErrorHandler(w http.ResponseWriter, r *http.Request, err error) {
	panic(err)
}