Skip to content

Commit

Permalink
fix: remove fatalError from BKTClient.shared
Browse files Browse the repository at this point in the history
  • Loading branch information
duyhungtnn committed Jul 25, 2023
1 parent b444efe commit aedde4e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Bucketeer.xcodeproj/xcshareddata/xcschemes/Bucketeer.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
BlueprintName = "BucketeerTests"
ReferencedContainer = "container:Bucketeer.xcodeproj">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "BucketeerE2ETests">
</Test>
</SkippedTests>
</TestableReference>
</Testables>
</TestAction>
Expand Down
11 changes: 10 additions & 1 deletion Bucketeer/Sources/Public/BKTClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,16 @@ extension BKTClient {
}

public static var shared: BKTClient {
return BKTClient.default ?? { fatalError("BKTClient is already initialized. Not sure if the initial fetch has finished") }()
get throws {
guard BKTClient.default != nil else {
throw BKTError.illegalState(message: "BKTClient is not initialized")
}
return BKTClient.default
// We do not want to crash the SDK's consumer app on runtime by using fatalError().
// So let the app has a chance to catch this exception
// The same behavior with the Android SDK

}
}

public func stringVariation(featureId: String, defaultValue: String) -> String {
Expand Down

0 comments on commit aedde4e

Please sign in to comment.