Skip to content

Commit

Permalink
Catch FileNotFoundException on contact import
Browse files Browse the repository at this point in the history
Resolves Qabel#791
  • Loading branch information
audax committed Jan 6, 2017
1 parent 346e043 commit 66e6c95
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import org.jetbrains.anko.runOnUiThread
import rx.Observable
import rx.subjects.BehaviorSubject
import java.io.File
import java.io.FileNotFoundException
import java.util.concurrent.TimeUnit
import javax.inject.Inject

Expand Down Expand Up @@ -234,7 +235,12 @@ class ContactsFragment() : ContactsView, BaseFragment(true, true, true), AnkoLog
when (action) {
is ExternalFileAction -> {
val uri = resultData?.data
val file = activity.contentResolver.openFileDescriptor(uri, action.accessMode)
val file = try {
activity.contentResolver.openFileDescriptor(uri, action.accessMode)
} catch (e: FileNotFoundException) {
showImportFailedMessage()
return
}
presenter.handleExternalFileAction(action, file.fileDescriptor)
}
else -> {
Expand Down

0 comments on commit 66e6c95

Please sign in to comment.