forked from fabric8-services/fabric8-wit
/
errors.go
47 lines (37 loc) · 1.1 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package remoteworkitem
import "fmt"
type simpleError struct {
message string
}
func (err simpleError) Error() string {
return err.message
}
// InternalError means that the operation failed for some internal, unexpected reason
type InternalError struct {
simpleError
}
// VersionConflictError means that the version was not as expected in an update operation
type VersionConflictError struct {
simpleError
}
// BadParameterError means that a parameter was not as required
type BadParameterError struct {
parameter string
value interface{}
}
// Error implements the error interface
func (err BadParameterError) Error() string {
return fmt.Sprintf("Bad value for parameter '%s': '%v'", err.parameter, err.value)
}
// ConversionError error means something went wrong converting between different representations
type ConversionError struct {
simpleError
}
// NotFoundError means the object specified for the operation does not exist
type NotFoundError struct {
entity string
ID string
}
func (err NotFoundError) Error() string {
return fmt.Sprintf("%s with id '%s' not found", err.entity, err.ID)
}