debian-forge-composer/internal/ostree/errors.go
Achilleas Koutsou 9e0af86775 ostree: rename errors and introduce ParameterComboError
Shorter and clearer error types.
- InvalidParameterError is now RefError.  It is returned when a ref (the
  new ref or the parent ref) is invalid.
- The ResolveRefError is not renamed.  It is returned when a ref can't
  be resolved (e.g., ref not found at URL).

New error type ParameterComboError.  It is returned when a parent ref is
specified but no URL, which is an invalid parameter combination.
2022-02-23 11:08:24 +01:00

47 lines
1.1 KiB
Go

package ostree
import "fmt"
// ResolveRefError is returned when there is a failure to resolve the
// reference.
type ResolveRefError struct {
msg string
}
func (e ResolveRefError) Error() string {
return e.msg
}
// NewResolveRefError creates and returns a new ResolveRefError with a given
// formatted message.
func NewResolveRefError(msg string, args ...interface{}) ResolveRefError {
return ResolveRefError{msg: fmt.Sprintf(msg, args...)}
}
// InvalidParamsError is returned when a parameter is invalid (e.g., malformed
// or contains illegal characters).
type RefError struct {
msg string
}
func (e RefError) Error() string {
return e.msg
}
// NewRefError creates and returns a new InvalidParameterError
// with a given formatted message.
func NewRefError(msg string, args ...interface{}) RefError {
return RefError{msg: fmt.Sprintf(msg, args...)}
}
type ParameterComboError struct {
msg string
}
func (e ParameterComboError) Error() string {
return e.msg
}
func NewParameterComboError(msg string, args ...interface{}) ParameterComboError {
return ParameterComboError{msg: fmt.Sprintf(msg, args...)}
}