// PanicHandler set a handler for unhandled panics
500420
func (app *App) PanicHandler(panicHandler func(*Context, interface{})) *App {
	app.defaultRouter.PanicHandler(panicHandler)
	return app
}
1364530
func SNIHandler(opts ...HandlerOption) Handler {
	h := &sniHandler{}
	h.Init(opts...)

	return h
}
441286
func (n *Node) errorHandler(ctx context.Context, err error) {
	n.logger.WithField("error", err).Info("error occurred")
}
676285
func RebalancerErrorHandler(h utils.ErrorHandler) RebalancerOption {
	return func(r *Rebalancer) error {
		r.errHandler = h
		return nil
	}
}
849973
func (n *LevelLogger) Panic(v ...interface{}) {
	if !n.Enabled() {
		return
	}
	s := fmt.Sprint(v...)
	n.mu.RLock()
	n.logger.Output(callDepth, s)
	n.mu.RUnlock()
	panic(s)
}
397767
func PanicHandler(h http.Handler, errH http.Handler) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		defer func() {
			if err := recover(); err != nil {
				if errH != nil {
					ew := &errResponseWriter{w, err}
					errH.ServeHTTP(ew, r)
				} else {
					http.Error(w, fmt.Sprintf("%s", err), http.StatusInternalServerError)
				}
			}
		}()

		// Call the protected handler
		h.ServeHTTP(w, r)
	}
}
1174254
func RecoveryHandler() func(http.Handler) http.Handler {
	return func(next http.Handler) http.Handler {
		return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
			defer func() {
				if r := recover(); r != nil {
					log := FromContext(req.Context())
					if log == nil {
						log = Logger("RecoveryHandler")
					}
					if err := LogPanicWithStack(log, "httpRecovery", r); err != nil {
						fmt.Fprintf(os.Stderr, "PanicLog failed! %q", err)
						panic(err)
					}
					http.Error(w, "internal processing error - please try again", http.StatusInternalServerError)
				}
			}()
			next.ServeHTTP(w, req)
		})
	}
}
383718
func ErrorHandler(h utils.ErrorHandler) ConnLimitOption {
	return func(cl *ConnLimiter) error {
		cl.errHandler = h
		return nil
	}
}
81884
func (me *Logger) Panic(v ...interface{}) {
	me.setFullPrefix(Pfatal)
	me.logger.Panic(v...)
}
776681
func panicHandler(logF *os.File) panicwrap.HandlerFunc {
	return func(m string) {
		// Right away just output this thing on stderr so that it gets
		// shown in case anything below fails.
		fmt.Fprintf(os.Stderr, fmt.Sprintf("%s\n", m))

		// Create the crash log file where we'll write the logs
		f, err := os.Create("crash.log")
		if err != nil {
			fmt.Fprintf(os.Stderr, "Failed to create crash log file: %s", err)
			return
		}
		defer f.Close()

		// Seek the log file back to the beginning
		if _, err = logF.Seek(0, 0); err != nil {
			fmt.Fprintf(os.Stderr, "Failed to seek log file for crash: %s", err)
			return
		}

		// Copy the contents to the crash file. This will include
		// the panic that just happened.
		if _, err = io.Copy(f, logF); err != nil {
			fmt.Fprintf(os.Stderr, "Failed to write crash log: %s", err)
			return
		}

		// Tell the user a crash occurred in some helpful way that
		// they'll hopefully notice.
		fmt.Printf("\n\n")
		fmt.Println(strings.TrimSpace(panicOutput))
	}
}
657768
func Panic(err error, message string, args ...interface{}) {
	if err != nil {
		logger.Printf(message+"\n", args...)
		panic(err)
	}
}
1181142
func (r *Router) UseHandler(handler http.Handler) *Router {
	r.Route("/*").All(handler.ServeHTTP)
	return r
}
886689
func (w *Worker) runHandler(h TaskHandler, t *Task) (err error) {

	defer func() {
		e := recover()
		if e != nil {
			err, _ = e.(error)
			log.Println("tasque: PANIC handling task: %s %s", t.Name, e)
		}

	}()
	err = h.Handle(t)
	return
}
1134682
func HTTPHandler(opts ...HandlerOption) Handler {
	h := &httpHandler{}
	h.Init(opts...)
	return h
}
1007428
func (c *Conn) CloseHandler() func(code int, text string) error {
	return c.handleClose
}
151144
func PanicFlatHandler(fx FlatHandler, p PanicHandler) FlatHandler {
	return func(c *Context, next NextHandler) {
		defer func() {
			if err := recover(); err != nil {
				p(c.Res, c.Req, err)
			}
		}()

		fx(c, next)
	}
}
1136741
func (cl *Listener) AddHandler(alpn string, handler Handler) {
	cl.l.Lock()
	cl.handlers[alpn] = handler
	cl.l.Unlock()
}