ostree: custom errors for ostree parameter validation
This commit is contained in:
parent
7f69d56fc9
commit
30e127d1b6
1 changed files with 35 additions and 0 deletions
35
internal/ostree/errors.go
Normal file
35
internal/ostree/errors.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
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 InvalidParameterError struct {
|
||||
msg string
|
||||
}
|
||||
|
||||
func (e InvalidParameterError) Error() string {
|
||||
return e.msg
|
||||
}
|
||||
|
||||
// NewInvalidParameterError creates and returns a new InvalidParameterError
|
||||
// with a given formatted message.
|
||||
func NewInvalidParameterError(msg string, args ...interface{}) InvalidParameterError {
|
||||
return InvalidParameterError{msg: fmt.Sprintf(msg, args...)}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue