Merge pull request #1340 from k9mail/crash_on_migration_error

Crash app when migrations fail in debug build
This commit is contained in:
Vincent 2016-05-02 14:55:43 +02:00
commit 28232ed108
2 changed files with 9 additions and 5 deletions

View file

@ -434,11 +434,10 @@ public class AccountSetupCheckSettings extends K9Activity implements OnClickList
afe.getMessage() == null ? "" : afe.getMessage());
} catch (CertificateValidationException cve) {
handleCertificateValidationException(cve);
} catch (Throwable t) {
Log.e(K9.LOG_TAG, "Error while testing settings", t);
showErrorDialog(
R.string.account_setup_failed_dlg_server_message_fmt,
(t.getMessage() == null ? "" : t.getMessage()));
} catch (Exception e) {
Log.e(K9.LOG_TAG, "Error while testing settings", e);
String message = e.getMessage() == null ? "" : e.getMessage();
showErrorDialog(R.string.account_setup_failed_dlg_server_message_fmt, message);
}
return null;
}

View file

@ -9,6 +9,7 @@ import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import com.fsck.k9.Account;
import com.fsck.k9.BuildConfig;
import com.fsck.k9.K9;
import com.fsck.k9.mail.Flag;
import com.fsck.k9.mailstore.migrations.Migrations;
@ -34,6 +35,10 @@ class StoreSchemaDefinition implements LockableDatabase.SchemaDefinition {
try {
upgradeDatabase(db);
} catch (Exception e) {
if (BuildConfig.DEBUG) {
throw new Error("Exception while upgrading database", e);
}
Log.e(K9.LOG_TAG, "Exception while upgrading database. Resetting the DB to v0", e);
db.setVersion(0);
upgradeDatabase(db);