Skip to content

Commit c2034e5

Browse files
authored
feat: add fatal error constructor (#445)
Signed-off-by: Todd Baert <[email protected]>
1 parent 7fd7ab6 commit c2034e5

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

openfeature/resolution_error.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,16 @@ func NewInvalidContextResolutionError(msg string) ResolutionError {
103103
}
104104
}
105105

106+
// NewProviderFatalResolutionError constructs a resolution error with code PROVIDER_FATAL
107+
//
108+
// Explanation - The provider is in an irrecoverable error state.
109+
func NewProviderFatalResolutionError(msg string) ResolutionError {
110+
return ResolutionError{
111+
code: ProviderFatalCode,
112+
message: msg,
113+
}
114+
}
115+
106116
// NewGeneralResolutionError constructs a resolution error with code GENERAL
107117
//
108118
// Explanation - The error was for a reason not enumerated above.
@@ -142,7 +152,7 @@ func (e *ProviderInitError) Error() string {
142152
//nolint:staticcheck // Renaming these would be a breaking change
143153
var (
144154
// ProviderNotReadyError signifies that an operation failed because the provider is in a NOT_READY state.
145-
ProviderNotReadyError = errors.New("provider not yet initialized")
155+
ProviderNotReadyError = NewProviderNotReadyResolutionError("provider not yet initialized")
146156
// ProviderFatalError signifies that an operation failed because the provider is in a FATAL state.
147-
ProviderFatalError = errors.New("provider is in an irrecoverable error state")
157+
ProviderFatalError = NewProviderFatalResolutionError("provider is in an irrecoverable error state")
148158
)

0 commit comments

Comments
 (0)