-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
57 lines (45 loc) · 1.65 KB
/
errors.go
File metadata and controls
57 lines (45 loc) · 1.65 KB
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
48
49
50
51
52
53
54
55
56
57
package client
import "fmt"
// RemoteError represents a generic error returned by remote Switcher API calls.
// Concrete remote error types embed RemoteError to allow type assertions by callers.
type RemoteError struct {
message string
}
func (e *RemoteError) Error() string {
return e.message
}
// RemoteAuthError indicates an authentication/authorization failure with the remote API.
// It embeds RemoteError.
type RemoteAuthError struct {
RemoteError
}
// RemoteCriteriaError indicates a criteria validation or execution error returned by the remote API.
// It embeds RemoteError.
type RemoteCriteriaError struct {
RemoteError
}
// RemoteSnapshotError indicates snapshot-related errors coming from the remote API.
// It embeds RemoteError.
type RemoteSnapshotError struct {
RemoteError
}
// LocalCriteriaError represents an error raised when local snapshot evaluation fails due to
// invalid criteria or inputs. It implements the error interface.
type LocalCriteriaError struct {
message string
}
func (e *LocalCriteriaError) Error() string {
return e.message
}
func newRemoteAuthError(format string, args ...any) error {
return &RemoteAuthError{RemoteError: RemoteError{message: fmt.Sprintf(format, args...)}}
}
func newRemoteCriteriaError(format string, args ...any) error {
return &RemoteCriteriaError{RemoteError: RemoteError{message: fmt.Sprintf(format, args...)}}
}
func newRemoteSnapshotError(format string, args ...any) error {
return &RemoteSnapshotError{RemoteError: RemoteError{message: fmt.Sprintf(format, args...)}}
}
func newLocalCriteriaError(format string, args ...any) error {
return &LocalCriteriaError{message: fmt.Sprintf(format, args...)}
}