diff --git a/picker-core/src/androidMain/kotlin/io/github/vinceglb/picker/core/Picker.android.kt b/picker-core/src/androidMain/kotlin/io/github/vinceglb/picker/core/Picker.android.kt index eeff882..16f2ff0 100644 --- a/picker-core/src/androidMain/kotlin/io/github/vinceglb/picker/core/Picker.android.kt +++ b/picker-core/src/androidMain/kotlin/io/github/vinceglb/picker/core/Picker.android.kt @@ -30,7 +30,7 @@ public actual object Picker { initialDirectory: String?, ): Out? = withContext(Dispatchers.IO) { // Throw exception if registry is not initialized - val registry = registry ?: throw IllegalStateException("Picker not initialized") + val registry = registry ?: throw PickerNotInitializedException() // It doesn't really matter what the key is, just that it is unique val key = UUID.randomUUID().toString() diff --git a/picker-core/src/androidMain/kotlin/io/github/vinceglb/picker/core/PickerNotInitializedException.kt b/picker-core/src/androidMain/kotlin/io/github/vinceglb/picker/core/PickerNotInitializedException.kt new file mode 100644 index 0000000..2346ffd --- /dev/null +++ b/picker-core/src/androidMain/kotlin/io/github/vinceglb/picker/core/PickerNotInitializedException.kt @@ -0,0 +1,4 @@ +package io.github.vinceglb.picker.core + +public class PickerNotInitializedException : + IllegalStateException("Picker not initialized on Android. Please call Picker.init(activity) first.") diff --git a/picker-core/src/androidMain/kotlin/io/github/vinceglb/picker/core/PickerSelectionMode.android.kt b/picker-core/src/androidMain/kotlin/io/github/vinceglb/picker/core/PickerSelectionMode.android.kt index 7826c9b..26dfcb6 100644 --- a/picker-core/src/androidMain/kotlin/io/github/vinceglb/picker/core/PickerSelectionMode.android.kt +++ b/picker-core/src/androidMain/kotlin/io/github/vinceglb/picker/core/PickerSelectionMode.android.kt @@ -14,7 +14,7 @@ public actual sealed class PickerSelectionMode { ) : PickerSelectionMode() { actual override fun result(selection: SelectionResult): PlatformFile? { val context = Picker.context.get() - ?: throw IllegalStateException("Picker context is not set") + ?: throw PickerNotInitializedException() return selection.files ?.firstOrNull() @@ -27,7 +27,7 @@ public actual sealed class PickerSelectionMode { ) : PickerSelectionMode() { override fun result(selection: SelectionResult): PlatformFiles? { val context = Picker.context.get() - ?: throw IllegalStateException("Picker context is not set") + ?: throw PickerNotInitializedException() return selection.files ?.takeIf { it.isNotEmpty() } diff --git a/samples/sample-core/composeApp/build.gradle.kts b/samples/sample-core/composeApp/build.gradle.kts index c4fc047..7489456 100644 --- a/samples/sample-core/composeApp/build.gradle.kts +++ b/samples/sample-core/composeApp/build.gradle.kts @@ -87,6 +87,7 @@ android { defaultConfig { minSdk = 24 + targetSdk = 34 } compileOptions {