Skip to content

Commit 6c78651

Browse files
committed
Added safe check
1 parent b7dd30e commit 6c78651

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

JetPDFVue/src/main/java/com/pratikk/jetpdfvue/state/VueFilePicker.kt

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,15 @@ class VueFilePicker {
159159
onError(e)
160160
null
161161
}
162-
file?.let {
163-
interceptResult(it)
164-
if (isActive) {
165-
onResult(file)
162+
try {
163+
file?.let {
164+
interceptResult(it)
165+
if (isActive) {
166+
onResult(file)
167+
}
166168
}
169+
} catch (e: Exception) {
170+
onError(e)
167171
}
168172
}
169173
}.apply {
@@ -185,8 +189,14 @@ class VueFilePicker {
185189
//Other sources
186190
VueFilePickerState.VueFilePickerImported(uri)
187191
} else {
188-
//From Camera
189-
VueFilePickerState.VueFilePickerImported(importFile!!.toUri())
192+
try {
193+
val uriFile = importFile!!.toUri()
194+
//From Camera
195+
VueFilePickerState.VueFilePickerImported(uriFile)
196+
} catch (e: Exception) {
197+
onError(e)
198+
VueFilePickerState.VueFilePickerIdeal
199+
}
190200
}
191201
} else {
192202
VueFilePickerState.VueFilePickerIdeal

0 commit comments

Comments
 (0)