// NewDownloadError returns a new error which indicates there was a problem
// when downloading a file
770099
func NewDownloadError(url string, code int) error {
	return Error{
		Message:    fmt.Sprintf("failed to retrieve %s, response code %d", url, code),
		Details:    nil,
		ErrorCode:  DownloadError,
		Suggestion: "check the availability of the address",
	}
}
252502
func NewAPIError(opName string, payload interface{}, code int) *APIError {
	return &APIError{
		OperationName: opName,
		Response:      payload,
		Code:          code,
	}
}
1312084
func NewReaderOnError(r io.Reader, notify func(error)) io.Reader {
	return &readerOnError{r, notify}
}
466787
func NewHTTPError(err error, msg string, status int) HTTPError {
	return HTTPError{err: err, msg: msg, status: status}
}
785872
func NewError(err error) *Error {
	e := &Error{}
	if err != nil {
		e.Store(err)
	}
	return e
}
989792
func NewError(line, column int, err string) *Error {
	return &Error{
		Line:   line,
		Column: column,
		Err:    err,
	}
}
434547
func (e NewDataVersionError) Error() string {
	return fmt.Sprintf(
		"The data at path %s is of a version (%d) that we can't read "+
			"(in folder %s)",
		e.path, e.DataVer, e.path.Tlf)
}
692014
func newError(err ResultError, context *JsonContext, value interface{}, locale locale, details ErrorDetails) {
	var t string
	var d string
	switch err.(type) {
	case *RequiredError:
		t = "required"
		d = locale.Required()
	case *InvalidTypeError:
		t = "invalid_type"
		d = locale.InvalidType()
	case *NumberAnyOfError:
		t = "number_any_of"
		d = locale.NumberAnyOf()
	case *NumberOneOfError:
		t = "number_one_of"
		d = locale.NumberOneOf()
	case *NumberAllOfError:
		t = "number_all_of"
		d = locale.NumberAllOf()
	case *NumberNotError:
		t = "number_not"
		d = locale.NumberNot()
	case *MissingDependencyError:
		t = "missing_dependency"
		d = locale.MissingDependency()
	case *InternalError:
		t = "internal"
		d = locale.Internal()
	case *ConstError:
		t = "const"
		d = locale.Const()
	case *EnumError:
		t = "enum"
		d = locale.Enum()
	case *ArrayNoAdditionalItemsError:
		t = "array_no_additional_items"
		d = locale.ArrayNoAdditionalItems()
	case *ArrayMinItemsError:
		t = "array_min_items"
		d = locale.ArrayMinItems()
	case *ArrayMaxItemsError:
		t = "array_max_items"
		d = locale.ArrayMaxItems()
	case *ItemsMustBeUniqueError:
		t = "unique"
		d = locale.Unique()
	case *ArrayContainsError:
		t = "contains"
		d = locale.ArrayContains()
	case *ArrayMinPropertiesError:
		t = "array_min_properties"
		d = locale.ArrayMinProperties()
	case *ArrayMaxPropertiesError:
		t = "array_max_properties"
		d = locale.ArrayMaxProperties()
	case *AdditionalPropertyNotAllowedError:
		t = "additional_property_not_allowed"
		d = locale.AdditionalPropertyNotAllowed()
	case *InvalidPropertyPatternError:
		t = "invalid_property_pattern"
		d = locale.InvalidPropertyPattern()
	case *InvalidPropertyNameError:
		t = "invalid_property_name"
		d = locale.InvalidPropertyName()
	case *StringLengthGTEError:
		t = "string_gte"
		d = locale.StringGTE()
	case *StringLengthLTEError:
		t = "string_lte"
		d = locale.StringLTE()
	case *DoesNotMatchPatternError:
		t = "pattern"
		d = locale.DoesNotMatchPattern()
	case *DoesNotMatchFormatError:
		t = "format"
		d = locale.DoesNotMatchFormat()
	case *MultipleOfError:
		t = "multiple_of"
		d = locale.MultipleOf()
	case *NumberGTEError:
		t = "number_gte"
		d = locale.NumberGTE()
	case *NumberGTError:
		t = "number_gt"
		d = locale.NumberGT()
	case *NumberLTEError:
		t = "number_lte"
		d = locale.NumberLTE()
	case *NumberLTError:
		t = "number_lt"
		d = locale.NumberLT()
	case *ConditionThenError:
		t = "condition_then"
		d = locale.ConditionThen()
	case *ConditionElseError:
		t = "condition_else"
		d = locale.ConditionElse()
	}

	err.SetType(t)
	err.SetContext(context)
	err.SetValue(value)
	err.SetDetails(details)
	err.SetDescriptionFormat(d)
	details["field"] = err.Field()

	if _, exists := details["context"]; !exists && context != nil {
		details["context"] = context.String()
	}

	err.SetDescription(formatErrorDescription(err.DescriptionFormat(), details))
}
259739
func newOpError(op string, err error) error {
	if err == nil {
		return nil
	}

	return &OpError{
		Op:  op,
		Err: err,
	}
}
1366596
func NewPullImageError(name string, err error) error {
	return Error{
		Message:    fmt.Sprintf("unable to get %s", name),
		Details:    err,
		ErrorCode:  PullImageError,
		Suggestion: fmt.Sprintf("check image name, or if using a local image set the builder image pull policy to %q", "never"),
	}
}
1040288
func NewError(code int, message string) *Error {
	return &Error{Code: code, Message: message}
}
1041574
func NewDownloadZipResult(Metadata *FolderMetadata) *DownloadZipResult {
	s := new(DownloadZipResult)
	s.Metadata = Metadata
	return s
}
1300099
func NewAllowDownloadDisabledType(Description string) *AllowDownloadDisabledType {
	s := new(AllowDownloadDisabledType)
	s.Description = Description
	return s
}
232960
func NewAllowDownloadEnabledType(Description string) *AllowDownloadEnabledType {
	s := new(AllowDownloadEnabledType)
	s.Description = Description
	return s
}
669606
func NewError(packageType string, method string, message string, args ...interface{}) DetailedError {
	return NewErrorWithError(nil, packageType, method, nil, message, args...)
}
278050
func NewApiError(code int, msg string) *Error {
	return &Error{
		apiError: &apiError{
			code: code,
			msg:  msg,
		},
		Err: nil,
	}
}
976118
func NewErrorFile(fs *FS) *SpecialReadFile {
	return &SpecialReadFile{read: libfs.GetEncodedErrors(fs.config), fs: fs}
}