Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private void handleDataSourceStatus(DataSourceStatusProvider.Status res, Complet
var message = res.getLastError() != null
? res.getLastError().toString()
: "the provider has encountered a permanent error or has been shutdown";
emitProviderError(ProviderEventDetails.builder().message(message).build());
emitProviderError(ProviderEventDetails.builder().message(message).errorCode(ErrorCode.GENERAL).build());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.launchdarkly.sdk.server.subsystems.ComponentConfigurer;
import com.launchdarkly.sdk.server.subsystems.DataSource;
import com.launchdarkly.sdk.server.subsystems.DataSourceUpdateSink;
import dev.openfeature.sdk.ErrorCode;
import dev.openfeature.sdk.ImmutableContext;
import dev.openfeature.sdk.OpenFeatureAPI;
import dev.openfeature.sdk.ProviderEvent;
Expand Down Expand Up @@ -357,6 +358,25 @@ public void itIncludesTheDataSourceErrorInErrorEvents() throws Exception {
assertTrue(message.contains("bad"));
}

@Test
public void itIncludesAnErrorCodeInErrorEvents() throws Exception {
var config = new LDConfig.Builder()
.startWait(Duration.ZERO)
.dataSource(new DelayedDataSourceFactory(Duration.ofMillis(100), false, true))
.events(Components.noEvents())
.build();
var provider = new Provider("fake-key", config);
CompletableFuture<ErrorCode> errorCode = new CompletableFuture<>();

OpenFeatureAPI.getInstance().on(ProviderEvent.PROVIDER_ERROR, (detail) -> {
errorCode.complete(detail.getErrorCode());
});

OpenFeatureAPI.getInstance().setProviderAndWait(provider);

assertEquals(ErrorCode.GENERAL, errorCode.get(1000, TimeUnit.MILLISECONDS));
}

@Test
public void itIncludesHttpDataSourceErrorInErrorEvents() throws Exception {
var config = new LDConfig.Builder()
Expand Down
Loading