Report OutOfMemoryError when importing and exporting messages
When importing/exporting large files we can run out of memory, in which case we should display a toast to the user (as we do for other exceptions). Previously, the OutOfMemoryError was not caught because it inherits from Error, not from Exception. (We have to manually call .toString() because Context.showErrorToast() from Commons takes an Exception or a String, not Throwable.)
This commit is contained in:
parent
1c7376c0f2
commit
1198a8c495
2 changed files with 4 additions and 4 deletions
|
|
@ -134,8 +134,8 @@ class SettingsActivity : SimpleActivity() {
|
|||
}
|
||||
toast(org.fossify.commons.R.string.exporting_successful)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
} catch (e: Throwable) { // also catch OutOfMemoryError etc.
|
||||
showErrorToast(e.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ class MessagesImporter(private val activity: SimpleActivity) {
|
|||
} else {
|
||||
importJson(uri)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
activity.showErrorToast(e)
|
||||
} catch (e: Throwable) { // also catch OutOfMemoryError etc.
|
||||
activity.showErrorToast(e.toString())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue