New error message #154

This commit is contained in:
J-Jamet
2018-07-30 21:10:11 +02:00
parent 60ccc450ae
commit 7cdb8db146
2 changed files with 15 additions and 11 deletions

View File

@@ -69,9 +69,7 @@ public class LoadDatabaseRunnable extends RunnableOnFinish {
public void run() {
try {
mDatabase.loadData(mContext, mUri, mPass, mKey, mStatus);
saveFileData(mUri, mKey);
} catch (ArcFourException e) {
catchError(e, R.string.error_arc4);
return;
@@ -85,8 +83,10 @@ public class LoadDatabaseRunnable extends RunnableOnFinish {
catchError(e, R.string.file_not_found);
return;
} catch (IOException e) {
Log.e(TAG, "Database can't be read", e);
finish(false, e.getMessage());
if (e.getMessage().contains("Hash failed with code"))
catchError(e, R.string.error_load_database_KDF_memory, true);
else
catchError(e, R.string.error_load_database, true);
return;
} catch (KeyFileEmptyException e) {
catchError(e, R.string.keyfile_is_empty);
@@ -107,22 +107,24 @@ public class LoadDatabaseRunnable extends RunnableOnFinish {
catchError(e, R.string.error_invalid_db);
return;
} catch (OutOfMemoryError e) {
String errorMessage = mContext.getString(R.string.error_out_of_memory);
Log.e(TAG, errorMessage, e);
finish(false, errorMessage);
catchError(e, R.string.error_out_of_memory);
return;
} catch (Exception e) {
Log.e(TAG, "Database can't be load", e);
finish(false, e.getMessage());
catchError(e, R.string.error_load_database, true);
return;
}
finish(true);
}
private void catchError(Exception e, @StringRes int messageId) {
private void catchError(Throwable e, @StringRes int messageId) {
catchError(e, messageId, false);
}
private void catchError(Throwable e, @StringRes int messageId, boolean addThrowableMessage) {
String errorMessage = mContext.getString(messageId);
Log.e(TAG, errorMessage, e);
if (addThrowableMessage)
errorMessage = errorMessage + " " + e.getLocalizedMessage();
finish(false, errorMessage);
}

View File

@@ -77,6 +77,8 @@
<string name="error_no_name">A name is required.</string>
<string name="error_nokeyfile">A keyfile is required.</string>
<string name="error_out_of_memory">The phone ran out of memory while parsing your database. It may be too large for your device.</string>
<string name="error_load_database">Database can\'t be load</string>
<string name="error_load_database_KDF_memory">Unable to load the key, try to decrease the memory used by the KDF.</string>
<string name="error_pass_gen_type">At least one password generation type must be selected</string>
<string name="error_pass_match">The passwords do not match.</string>
<string name="error_rounds_not_number">\"Rounds\" must be a number.</string>