From 11fa85f57044a3938ee5981a1477e62f8abeb4fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=97=BB=E6=98=8A?= Date: Fri, 15 Nov 2024 11:06:21 +0800 Subject: [PATCH] feat: support throw exception when initialization fails --- src/main/kotlin/com/statsig/sdk/StatsigOptions.kt | 1 + src/main/kotlin/com/statsig/sdk/StatsigServer.kt | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/main/kotlin/com/statsig/sdk/StatsigOptions.kt b/src/main/kotlin/com/statsig/sdk/StatsigOptions.kt index 5b757ce..19bd6c1 100644 --- a/src/main/kotlin/com/statsig/sdk/StatsigOptions.kt +++ b/src/main/kotlin/com/statsig/sdk/StatsigOptions.kt @@ -132,6 +132,7 @@ class StatsigOptions( var fallbackToStatsigAPI: Boolean = false, var disableIPResolution: Boolean = false, var userPersistentStorage: IUserPersistentStorage? = null, + var setupFailThrowError: Boolean = false, ) { constructor(api: String) : this(api, DEFAULT_INIT_TIME_OUT_MS) constructor(initTimeoutMs: Long) : this(STATSIG_API_URL_BASE, initTimeoutMs) diff --git a/src/main/kotlin/com/statsig/sdk/StatsigServer.kt b/src/main/kotlin/com/statsig/sdk/StatsigServer.kt index 76ab213..6df282e 100644 --- a/src/main/kotlin/com/statsig/sdk/StatsigServer.kt +++ b/src/main/kotlin/com/statsig/sdk/StatsigServer.kt @@ -310,6 +310,9 @@ private class StatsigServerImpl() : // noop swallow and let other part handle error options.customLogger.warn("Failed to setup sdk") options.customLogger.warn(e.stackTraceToString()) + if (options.setupFailThrowError) { + throw e + } } }