// CaptureError sends error 'err' to Sentry, meanwhile also sets user
// information by extracting user information from the context provided
979121
func (c *client) CaptureError(ctx context.Context, err error) {
	// if method called during test which has uninitialized client
	if c == nil {
		return
	}
	// Extract user information. Ignoring error here but then before using the
	// object user make sure to check if it wasn't nil.
	user, _ := extractUserInfo(ctx)
	reqID := log.ExtractRequestID(ctx)

	c.sendErr <- func() {
		if user != nil {
			c.c.SetUserContext(user)
		}

		additionalContext := make(map[string]string)
		if reqID != "" {
			additionalContext["req_ID"] = reqID
		}

		c.c.CaptureError(err, additionalContext)
		c.c.ClearContext()
	}
}
667849
func recordError(operation string, err error) {
	if err != nil {
		metrics.RuntimeOperationsErrors.WithLabelValues(operation).Inc()
		metrics.DeprecatedRuntimeOperationsErrors.WithLabelValues(operation).Inc()
	}
}
459069
func DefaultErrorEncoder(_ context.Context, err error, reply string, nc *nats.Conn) {
	logger := log.NewNopLogger()

	type Response struct {
		Error string `json:"err"`
	}

	var response Response

	response.Error = err.Error()

	b, err := json.Marshal(response)
	if err != nil {
		logger.Log("err", err)
		return
	}

	if err := nc.Publish(reply, b); err != nil {
		logger.Log("err", err)
	}
}
1035610
func recordError(operation string, err error) {
	if err != nil {
		// TODO(runcom): handle timeout from ctx as well
		metrics.CRIOOperationsErrors.WithLabelValues(operation).Inc()
	}
}
361167
func recordTryError(try *parallel.Try, err error) {
	logger.Infof("%v", err)
	try.Start(func(_ <-chan struct{}) (io.Closer, error) {
		return nil, errors.Trace(err)
	})
}
390501
func (c *Client) UseError(fn context.HandlerFunc) *Client {
	c.Middleware.UseError(fn)
	return c
}
1089451
func (req *SrvReq) RespondError(err interface{}) {
	switch e := err.(type) {
	case *Error:
		PackRerror(req.Rc, e.Error(), uint32(e.Errornum), req.Conn.Dotu)
	case error:
		PackRerror(req.Rc, e.Error(), uint32(EIO), req.Conn.Dotu)
	default:
		PackRerror(req.Rc, fmt.Sprintf("%v", e), uint32(EIO), req.Conn.Dotu)
	}

	req.Respond()
}
969703
func ctxSetErr(r *http.Request, err error) *http.Request {
	Logger.Info("cannot set error in context", "err", err)
	return r
}
1360159
func ContextErr(err error) error {
	switch err {
	case context.DeadlineExceeded:
		return status.Error(codes.DeadlineExceeded, err.Error())
	case context.Canceled:
		return status.Error(codes.Canceled, err.Error())
	}
	return status.Errorf(codes.Internal, "Unexpected error from context packet: %v", err)
}
729260
func CaptureErrorAndWait(err error, tags map[string]string, interfaces ...Interface) string {
	return DefaultClient.CaptureErrorAndWait(err, tags, interfaces...)
}
127613
func HandleError(h httpx.Handler, f ErrorHandlerFunc) *Error {
	e := NewError(h)
	e.ErrorHandler = f
	return e
}
777008
func WrapRetryableError(err error, errorList []*regexp.Regexp, errorCreator ErrorCreator) error {
	if err == nil {
		return nil
	}
	for _, errorRegex := range errorList {
		if errorRegex.MatchString(err.Error()) {
			return errorCreator(err)
		}
	}
	return err
}
302169
func MaskError(err error) bool {
	_, ok := errors.Cause(err).(*k8serrors.StatusError)
	return ok
}
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
}
268507
func (defaultErrorHandler) HandleError(err error, w http.ResponseWriter, req *http.Request) {
	w.WriteHeader(http.StatusInternalServerError)
	fmt.Fprintf(w, "Error: %s", err)
}
133444
func RecoverError(resp *ResponseError) error {
	if resp == nil {
		return nil
	}
	switch resp.Code {
	case "invalid":
		return lease.ErrInvalid
	case "concurrent-update":
		return globalclock.ErrConcurrentUpdate
	default:
		return errors.New(resp.Message)
	}
}
324375
func (d *Decoder) syntaxError(msg string) error {
	return &SyntaxError{Msg: msg, Line: d.line}
}