Skip to content

Commit

Permalink
refactor: add exception on missing default
Browse files Browse the repository at this point in the history
  • Loading branch information
timschneeb committed Jul 22, 2023
1 parent ea7ff1d commit 2c7538c
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ class Preferences(val context: Context) {
},
BuildConfig.APPLICATION_ID
)

if(defaultRes == 0) {
throw IllegalStateException("Preference key '$key' has no default set")
}

(when(type) {
Boolean::class -> context.resources.getBoolean(defaultRes)
String::class -> context.resources.getString(defaultRes)
Expand Down

0 comments on commit 2c7538c

Please sign in to comment.