mirror of
https://github.com/FossifyOrg/Messages.git
synced 2026-06-18 13:28:42 -04:00
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:
@@ -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())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user