Skip to content

Commit

Permalink
chore: moved sentinel errors into appropriate file
Browse files Browse the repository at this point in the history
Signed-off-by: Bernd Warmuth <[email protected]>
  • Loading branch information
warber committed Nov 7, 2024
1 parent 9695ff6 commit ccfb895
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
22 changes: 0 additions & 22 deletions openfeature/error.go
Original file line number Diff line number Diff line change
@@ -1,23 +1 @@
package openfeature

import (
"errors"
"fmt"
)

// ProviderInitError represents an error that occurs during provider initialization.
type ProviderInitError struct {
ErrorCode ErrorCode // Field to store the specific error code
Message string // Custom error message
}

// Error implements the error interface for ProviderInitError.
func (e *ProviderInitError) Error() string {
return fmt.Sprintf("ProviderInitError: %s (code: %s)", e.Message, e.ErrorCode)
}

// ProviderNotReadyError signifies that an operation failed because the provider is in a NOT_READY state.
var ProviderNotReadyError = errors.New("provider not yet initialized")

// ProviderFatalError signifies that an operation failed because the provider is in a FATAL state.
var ProviderFatalError = errors.New("provider is in an irrecoverable error state")
23 changes: 22 additions & 1 deletion openfeature/resolution_error.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package openfeature

import "fmt"
import (
"errors"
"fmt"
)

type ErrorCode string

Expand Down Expand Up @@ -104,3 +107,21 @@ func NewGeneralResolutionError(msg string) ResolutionError {
message: msg,
}
}

// ProviderInitError represents an error that occurs during provider initialization.
type ProviderInitError struct {
ErrorCode ErrorCode // Field to store the specific error code
Message string // Custom error message
}

// Error implements the error interface for ProviderInitError.
func (e *ProviderInitError) Error() string {
return fmt.Sprintf("ProviderInitError: %s (code: %s)", e.Message, e.ErrorCode)
}

var (
// ProviderNotReadyError signifies that an operation failed because the provider is in a NOT_READY state.
ProviderNotReadyError = errors.New("provider not yet initialized")
// ProviderFatalError signifies that an operation failed because the provider is in a FATAL state.
ProviderFatalError = errors.New("provider is in an irrecoverable error state")
)

0 comments on commit ccfb895

Please sign in to comment.