// handleError is called by the main work loop to check the return of calling handleBuildConfig
// If an error occurred, then the key is re-added to the queue unless it has been retried too many
// times.
353039
func (c *BuildConfigController) handleError(err error, key interface{}) {
	if err == nil {
		c.queue.Forget(key)
		return
	}

	if IsFatal(err) {
		klog.V(2).Infof("Will not retry fatal error for key %v: %v", key, err)
		c.queue.Forget(key)
		return
	}

	if c.queue.NumRequeues(key) < maxRetries {
		klog.V(4).Infof("Retrying key %v: %v", key, err)
		c.queue.AddRateLimited(key)
		return
	}

	klog.V(2).Infof("Giving up retrying %v: %v", key, err)
	c.queue.Forget(key)
}
267740
func (h *Handler) Handle(err error) {
	// Get the context from the error
	ctx := keyvals.ToMap(emperror.Context(err))

	// Expose the stackTracer interface on the outer error (if there is stack trace in the error)
	// Convert error with stack trace to an internal error type
	if e, ok := emperror.ExposeStackTrace(err).(stackTracer); ok {
		err = newCauseStacker(e)
	}

	if req, ok := httperr.HTTPRequest(err); ok {
		h.client.RequestErrorWithStackSkipWithExtras(rollbar.ERR, req, err, 3, ctx)

		return
	}

	h.client.ErrorWithStackSkipWithExtras(rollbar.ERR, err, 3, ctx)
}
71967
func ResponseError(format string, a ...interface{}) {
	response := ErrorResponse{Error: fmt.Sprintf(format, a...)}
	j, err := json.MarshalIndent(&response, "", "\t")
	if err != nil {
		panic(fmt.Sprintf("Failed to generate response for error:", err))
	}
	fmt.Println(string(j[:]))
}
357406
func (sm *ServeMux) MWError(handler HandlerFunc) http.HandlerFunc {
	return func(w http.ResponseWriter, req *http.Request) {
		ww := NewResponseWriter(w)
		if err := handler(ww, req); err != nil {
			sm.HandleError(ww, req, err)
			return
		}
	}
}
431084
func (s *Layer) UseError(fn c.HandlerFunc) Middleware {
	s.mtx.Lock()
	s.stack = append(s.stack, plugin.NewErrorPlugin(fn))
	s.mtx.Unlock()
	return s
}
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)
}
319770
func (m *Module) HandleError(rw http.ResponseWriter, req *http.Request, err error) int {
	switch err {
	case ErrNotFound:
		err = NewRequestError(req, http.StatusNotFound, "not found: "+req.URL.String())
	case ErrNotAuthorized:
		err = NewRequestError(req, http.StatusUnauthorized, "not authenticated")
	case ErrForbidden:
		err = NewRequestError(req, http.StatusForbidden, "forbidden")
	case ErrInternal:
		err = NewRequestError(req, http.StatusInternalServerError, "internal server error")
	}

	switch e := err.(type) {
	// handle wrapped error created by errors.Wrap
	case *errors.Error:
		// log (warn) the stack trace and then recurse on the original err, which
		// is either a known *Error or unknown error
		m.Logger.Warning(errString(err))
		return m.HandleError(rw, req, e.Err)

	case *Error:
		status := int(e.err.GetCode())
		if status >= 500 {
			m.Logger.Error(e) // log the original error (with request)
		} else {
			m.Logger.Warning(err)
		}
		if e.silent {
			rw.WriteHeader(status)
		} else if e.redirect {
			m.ErrorPage(rw, req, status)
		} else {
			Proto(rw, int(e.err.GetCode()), &api.ErrorResponse{Errors: []*api.Error{&e.err}})
		}
		return status

	default:
		// log error with request
		m.Logger.Error(&Error{
			request: req,
			err:     newAPIError(500, errString(e)),
		})
		ae := newAPIError(http.StatusInternalServerError, "internal server error")
		Proto(rw, http.StatusInternalServerError, &api.ErrorResponse{Errors: []*api.Error{&ae}})
		return http.StatusInternalServerError
	}
}
1266019
func (DebugErrorMessageHandler) HandleErrorMessage(error ErrorCode) []byte {
	fmt.Fprintf(standardErrorOutput, "%sHandleErrorMessage(%s)\n", debugPrefix, error)
	return nil
}
1118827
func (h *Handler) Handle(err error) {
	// Expose the stackTracer interface on the outer error (if there is stack trace in the error)
	// Convert error with stack trace to an internal error type
	if e, ok := emperror.ExposeStackTrace(err).(stackTracer); ok {
		err = newErrorWithStackFrames(e)
	}

	var rawData []interface{}

	if cause := errors.Cause(err); cause != nil {
		if name := reflect.TypeOf(cause).String(); len(name) > 0 {
			errorClass := bugsnag.ErrorClass{Name: name}

			rawData = append(rawData, errorClass)
		}
	}

	if ctx := emperror.Context(err); len(ctx) > 0 {
		rawData = append(rawData, bugsnag.MetaData{
			"Params": keyvals.ToMap(ctx),
		})
	}

	_ = h.notifier.Notify(err, rawData...)
}
1045884
func HandleError(w ResponseWriter, req *http.Request, err error) {
	DefaultServeMux.HandleError(w, req, err)
}
1286822
func ErrorHandler(eh ErrorHandlerFunc) func(*Configuration) error {
	return func(c *Configuration) error {
		c.errorHandler = eh
		return nil
	}
}
791475
func (h *memberLookupMemberNotFoundSuppressor) HandleError(err error) (bool, error) {
	memberLookupError, isMemberLookupError := err.(*memberLookupError)
	if !isMemberLookupError {
		return false, nil
	}

	if ldaputil.IsEntryNotFoundError(memberLookupError.causedBy) || ldaputil.IsNoSuchObjectError(memberLookupError.causedBy) {
		fmt.Fprintf(h.err, "For group %q, ignoring member %q: %v\n", memberLookupError.ldapGroupUID, memberLookupError.ldapUserUID, memberLookupError.causedBy)
		return true, nil
	}

	return false, nil
}
292438
func handleV2Error(ctx *web.Context, j *factom.JSON2Request, err *factom.JSONError) {
	resp := factom.NewJSON2Response()
	if j != nil {
		resp.ID = j.ID
	} else {
		resp.ID = nil
	}
	resp.Error = err

	ctx.WriteHeader(httpBad)
	ctx.Write([]byte(resp.String()))
}
1176011
func (h *backupHandler) sendError(w http.ResponseWriter, err error) {
	err, status := common.ServerErrorAndStatus(err)
	if err := sendStatusAndJSON(w, status, err); err != nil {
		logger.Errorf("%v", err)
	}
}
745909
func (h *compoundHandler) HandleError(err error) (bool, error) {
	for _, handler := range h.handlers {
		handled, handleErr := handler.HandleError(err)
		if handled || handleErr != nil {
			return handled, handleErr
		}
	}

	return false, nil
}
720366
func (we *WorkflowExecutor) HandleError() {
	if r := recover(); r != nil {
		_ = we.AddAnnotation(common.AnnotationKeyNodeMessage, fmt.Sprintf("%v", r))
		log.Fatalf("executor panic: %+v\n%s", r, debug.Stack())
	} else {
		if len(we.errors) > 0 {
			_ = we.AddAnnotation(common.AnnotationKeyNodeMessage, we.errors[0].Error())
		}
	}
}
391258
func HandlerErrorHandler(errorHandler transport.ErrorHandler) HandlerOption {
	return func(h *Handler) { h.errorHandler = errorHandler }
}