Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/open_feature/sdk/provider/no_op_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module Provider
# * <tt>fetch_object_value</tt> - Retrieve feature flag object value
#
class NoOpProvider
REASON_NO_OP = "No-op"
REASON_NO_OP = Reason::DEFAULT
NAME = "No-op Provider"
Comment thread
cristiangmarta marked this conversation as resolved.

attr_reader :metadata
Expand Down
4 changes: 2 additions & 2 deletions lib/open_feature/sdk/provider_initialization_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class ProviderInitializationError < StandardError
# @param message [String] the error message
# @param provider [Object] the provider that failed to initialize
# @param original_error [Exception] the original error that caused the failure
# @param error_code [String] the OpenFeature error code (defaults to PROVIDER_FATAL)
def initialize(message, provider: nil, original_error: nil, error_code: Provider::ErrorCode::PROVIDER_FATAL)
# @param error_code [String] the OpenFeature error code (defaults to GENERAL)
def initialize(message, provider: nil, original_error: nil, error_code: Provider::ErrorCode::GENERAL)
super(message)
@provider = provider
@original_error = original_error
Expand Down
7 changes: 5 additions & 2 deletions spec/open_feature/sdk/hooks/logging_hook_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,15 @@
end

it "uses error_code from exception when available" do
error_with_code = OpenFeature::SDK::ProviderInitializationError.new("init failed")
error_with_code = OpenFeature::SDK::ProviderInitializationError.new(
"init failed",
error_code: "CUSTOM_ERROR_CODE"
)
hook = described_class.new(logger: logger)

expect(logger).to receive(:error) do |&block|
message = block.call
expect(message).to include("error_code=PROVIDER_FATAL")
expect(message).to include("error_code=CUSTOM_ERROR_CODE")
end

hook.error(hook_context: hook_context, exception: error_with_code, hints: hints)
Expand Down
8 changes: 4 additions & 4 deletions spec/open_feature/sdk/provider_initialization_error_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
expect(error).to be_a(StandardError)
end

it "sets the error code to PROVIDER_FATAL by default" do
expect(error.error_code).to eq(OpenFeature::SDK::Provider::ErrorCode::PROVIDER_FATAL)
it "sets the error code to GENERAL by default" do
expect(error.error_code).to eq(OpenFeature::SDK::Provider::ErrorCode::GENERAL)
end
end

Expand All @@ -49,8 +49,8 @@
expect(error.original_error).to be_nil
end

it "sets the error code to PROVIDER_FATAL by default" do
expect(error.error_code).to eq(OpenFeature::SDK::Provider::ErrorCode::PROVIDER_FATAL)
it "sets the error code to GENERAL by default" do
expect(error.error_code).to eq(OpenFeature::SDK::Provider::ErrorCode::GENERAL)
end
end

Expand Down
Loading