// ErrorCode returns the code of the root error, if available; otherwise returns EINTERNAL.
973051
func ErrorCode(err error) string {
	if err == nil {
		return ""
	}

	e, ok := err.(*Error)
	if !ok {
		return EInternal
	}

	if e == nil {
		return ""
	}

	if e.Code != "" {
		return e.Code
	}

	if e.Err != nil {
		return ErrorCode(e.Err)
	}

	return EInternal
}
312266
func (o *AddCommentToTaskDefault) WithXErrorCode(xErrorCode string) *AddCommentToTaskDefault {
	o.XErrorCode = xErrorCode
	return o
}
940862
func (s *BatchItemError) SetErrorCode(v string) *BatchItemError {
	s.ErrorCode = &v
	return s
}
57
func (r *Rets) SetErrorCode() string {
	const code = `if r0 != 0 {
		%s = %sErrno(r0)
	}`
	if r.Name == "" && !r.ReturnsError {
		return ""
	}
	if r.Name == "" {
		return r.useLongHandleErrorCode("r1")
	}
	if r.Type == "error" {
		return fmt.Sprintf(code, r.Name, syscalldot())
	}
	s := ""
	switch {
	case r.Type[0] == '*':
		s = fmt.Sprintf("%s = (%s)(unsafe.Pointer(r0))", r.Name, r.Type)
	case r.Type == "bool":
		s = fmt.Sprintf("%s = r0 != 0", r.Name)
	default:
		s = fmt.Sprintf("%s = %s(r0)", r.Name, r.Type)
	}
	if !r.ReturnsError {
		return s
	}
	return s + "\n\t" + r.useLongHandleErrorCode(r.Name)
}
1321591
func (s *EnvironmentError) SetErrorCode(v string) *EnvironmentError {
	s.ErrorCode = &v
	return s
}
952954
func (s *ErrorDetail) SetErrorCode(v string) *ErrorDetail {
	s.ErrorCode = &v
	return s
}
1018208
func (s *UnprocessedIdentityId) SetErrorCode(v string) *UnprocessedIdentityId {
	s.ErrorCode = &v
	return s
}
1207205
func (o *GetTaskDetailsDefault) WithXErrorCode(xErrorCode string) *GetTaskDetailsDefault {
	o.XErrorCode = xErrorCode
	return o
}
371349
func (e ErrorCode) String() string {
	if e < ErrorCode(len(errStrs)) {
		return errStrs[e]
	}
	return fmt.Sprintf("ErrorCode(%d)", e)
}
621548
func ErrorMessage(err error) string {
	if err == nil {
		return ""
	}

	e, ok := err.(*Error)
	if !ok {
		return "An internal error has occurred."
	}

	if e == nil {
		return ""
	}

	if e.Msg != "" {
		return e.Msg
	}

	if e.Err != nil {
		return ErrorMessage(e.Err)
	}

	return "An internal error has occurred."
}
36653
func ConvertHTTPErrorCode(statusCode int, responseBody string) error {

	switch statusCode {

	case http.StatusNotFound:
		return errors.NewNotFoundErrorFromString(responseBody)

	case http.StatusBadRequest:
		return errors.NewBadParameterErrorFromString(responseBody)

	case http.StatusConflict:
		return errors.NewDataConflictError(responseBody)

	case http.StatusUnauthorized:
		return errors.NewUnauthorizedError(responseBody)

	case http.StatusForbidden:
		return errors.NewForbiddenError(responseBody)

	default:
		return errors.NewInternalErrorFromString(responseBody)
	}
}
560401
func (s *Workspace) SetErrorCode(v string) *Workspace {
	s.ErrorCode = &v
	return s
}
304890
func (c *Context) Code(code int) (err error) {
	c.response.WriteHeader(code)
	return
}
405772
func (s *WorkspaceImage) SetErrorCode(v string) *WorkspaceImage {
	s.ErrorCode = &v
	return s
}
103496
func IsCode(code string, err error) bool {
	if argoErr, ok := err.(argoerr); ok {
		return argoErr.code == code
	}
	return false

}
514840
func (s *UnprocessedStatistics) SetErrorCode(v string) *UnprocessedStatistics {
	s.ErrorCode = &v
	return s
}
732967
func errorCode(err error) codes.Code {
	switch errors.Unwrap(err) {
	case context.DeadlineExceeded:
		return codes.DeadlineExceeded

	case context.Canceled:
		return codes.Canceled

	default:
		return grpc.Code(err)
	}
}