// GetPrettyErrorForServer prettifys the message of the provided error
548562
func getPrettyErrorForServer(err error, serverName string) error {
	return errors.New(getPrettyMessageForServer(err, serverName))
}
260242
func formatError(format string, err error) error {
	if s, ok := err.(errors.APIStatus); ok {
		se := &errors.StatusError{ErrStatus: s.Status()}
		se.ErrStatus.Message = fmt.Sprintf(format, se.ErrStatus.Message)
		return se
	}
	return fmt.Errorf(format, err)
}
1073000
func getProjServer(c context.Context) projects.ProjectsServer {
	return c.Value(&prjKey).(projects.ProjectsServer)
}
843076
func checkForEmptyError(err error) error {
	if err != nil {
		return nil
	}
	msg := "attempted to notify Bugsnag without supplying an error. Bugsnag not notified"
	Config.Logger.Printf("ERROR: " + msg)
	return fmt.Errorf(msg)
}
944049
func GetErrorBody(err error) string {
	rv := errors.GetData(err, errorBody)
	message, ok := rv.(string)
	if !ok {
		return errors.GetMessage(err)
	}
	class := errors.GetClass(err)
	if class == nil {
		return message
	}
	return fmt.Sprintf("%s: %s", class.String(), message)
}
286359
func getSTSErrorResponse(err STSError, requestID string) STSErrorResponse {
	errRsp := STSErrorResponse{}
	errRsp.Error.Code = err.Code
	errRsp.Error.Message = err.Description
	errRsp.RequestID = requestID
	return errRsp
}
1369303
func ServerError(err error) *params.Error {
	if err == nil {
		return nil
	}
	logger.Tracef("server RPC error %v", errors.Details(err))

	var (
		info map[string]interface{}
		msg  = err.Error()
	)

	// Skip past annotations when looking for the code.
	err = errors.Cause(err)
	code, ok := singletonCode(err)
	switch {
	case ok:
	case errors.IsUnauthorized(err):
		code = params.CodeUnauthorized
	case errors.IsNotFound(err):
		code = params.CodeNotFound
	case errors.IsUserNotFound(err):
		code = params.CodeUserNotFound
	case errors.IsAlreadyExists(err):
		code = params.CodeAlreadyExists
	case errors.IsNotAssigned(err):
		code = params.CodeNotAssigned
	case state.IsHasAssignedUnitsError(err):
		code = params.CodeHasAssignedUnits
	case state.IsHasHostedModelsError(err):
		code = params.CodeHasHostedModels
	case state.IsHasPersistentStorageError(err):
		code = params.CodeHasPersistentStorage
	case state.IsModelNotEmptyError(err):
		code = params.CodeModelNotEmpty
	case isNoAddressSetError(err):
		code = params.CodeNoAddressSet
	case errors.IsNotProvisioned(err):
		code = params.CodeNotProvisioned
	case IsUpgradeInProgressError(err):
		code = params.CodeUpgradeInProgress
	case state.IsHasAttachmentsError(err):
		code = params.CodeMachineHasAttachedStorage
	case state.IsStorageAttachedError(err):
		code = params.CodeStorageAttached
	case isUnknownModelError(err):
		code = params.CodeModelNotFound
	case errors.IsNotSupported(err):
		code = params.CodeNotSupported
	case errors.IsBadRequest(err):
		code = params.CodeBadRequest
	case errors.IsMethodNotAllowed(err):
		code = params.CodeMethodNotAllowed
	case errors.IsNotImplemented(err):
		code = params.CodeNotImplemented
	case state.IsIncompatibleSeriesError(err):
		code = params.CodeIncompatibleSeries
	case IsDischargeRequiredError(err):
		dischErr := errors.Cause(err).(*DischargeRequiredError)
		code = params.CodeDischargeRequired
		info = params.DischargeRequiredErrorInfo{
			Macaroon: dischErr.Macaroon,
			// One macaroon fits all.
			MacaroonPath: "/",
		}.AsMap()
	case IsRedirectError(err):
		redirErr := errors.Cause(err).(*RedirectError)
		code = params.CodeRedirect
		info = params.RedirectErrorInfo{
			Servers:         params.FromNetworkHostsPorts(redirErr.Servers),
			CACert:          redirErr.CACert,
			ControllerAlias: redirErr.ControllerAlias,
		}.AsMap()
	default:
		code = params.ErrCode(err)
	}

	return &params.Error{
		Message: msg,
		Code:    code,
		Info:    info,
	}
}
1285945
func errorProcessorFunc(err error) ProcessorFunc {
	return func(in string) (string, bool) {
		return fmt.Sprintf("error processing '%s': %v", in, err), false
	}
}
1304252
func RenderErrorFromArray(errors []interface{}) string {
	buf := new(bytes.Buffer)

	for _, err := range errors {
		fmt.Fprintf(buf, " %s,", err.(string))
	}

	return buf.String()
}
1329170
func ReasonForError(err error) metav1.StatusReason {
	switch t := err.(type) {
	case APIStatus:
		return t.Status().Reason
	}
	return metav1.StatusReasonUnknown
}
369305
func messageForError(err error) string {
	msg, ok := StandardErrorMessage(err)
	if !ok {
		msg = err.Error()
	}
	return msg
}
783554
func (slc *HttpClient) CheckForHttpResponseErrorsSilently(data []byte) error {
	var decodedResponse map[string]interface{}
	parseErr := json.Unmarshal(data, &decodedResponse)
	if parseErr == nil {
		return slc.HasErrors(decodedResponse)
	}

	return nil
}
1092372
func getError(r *http.Response, req *http.Request) error {
	if c := r.StatusCode; 200 <= c && c <= 299 {
		return nil
	}

	errorResponse := &ErrorResponse{Response: r}
	data, err := ioutil.ReadAll(r.Body)
	if err == nil && data != nil {
		json.Unmarshal(data, errorResponse)
	}
	errorResponse.Status = r.Status
	errorResponse.StatusCode = r.StatusCode
	errorResponse.Request = req

	switch r.StatusCode {
	case http.StatusBadRequest:
		return &ErrBadRequest{ErrorResponse: errorResponse}
	case http.StatusUnauthorized:
		return &ErrUnauthorized{ErrorResponse: errorResponse}
	case http.StatusServiceUnavailable:
		return &ErrTemporarilyUnavailable{ErrorResponse: errorResponse}
	case http.StatusNotFound:
		return &ErrNotFound{ErrorResponse: errorResponse}
	case http.StatusGone:
		return &ErrDeleted{ErrorResponse: errorResponse}
	default:
		return &ErrUnexpected{ErrorResponse: errorResponse}
	}
}
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()
	}
}
648886
func (c *Client) GetPrefilter() (*models.Prefilter, error) {
	resp, err := c.Prefilter.GetPrefilter(nil)
	if err != nil {
		return nil, Hint(err)
	}
	return resp.Payload, nil
}
191433
func getAPIErrorResponse(ctx context.Context, err APIError, resource, requestID, hostID string) APIErrorResponse {
	reqInfo := logger.GetReqInfo(ctx)
	return APIErrorResponse{
		Code:       err.Code,
		Message:    err.Description,
		BucketName: reqInfo.BucketName,
		Key:        reqInfo.ObjectName,
		Resource:   resource,
		RequestID:  requestID,
		HostID:     hostID,
	}
}
1203842
func (cs *Stats) GetError() error {
	cs.mutex.Lock()
	defer cs.mutex.Unlock()
	return cs.err
}