Merge pull request #7145 from thundernest/change_import_logging

Add error messages to allow better import debugging
This commit is contained in:
Wolf-Martell Montwé 2023-08-30 14:15:31 +02:00 committed by GitHub
commit 5b4cee05ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 6 deletions

View file

@ -243,6 +243,13 @@ public class Settings {
static class InvalidSettingValueException extends Exception { static class InvalidSettingValueException extends Exception {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public InvalidSettingValueException() {
}
public InvalidSettingValueException(String message) {
super(message);
}
} }
/** /**

View file

@ -253,8 +253,12 @@ public class SettingsImporter {
erroneousAccounts.add(importResult.original); erroneousAccounts.add(importResult.original);
} }
} catch (InvalidSettingValueException e) { } catch (InvalidSettingValueException e) {
Timber.e(e, "Encountered invalid setting while importing account \"%s\"", String reason = e.getMessage();
account.name); if (TextUtils.isEmpty(reason)) {
reason = "Unknown";
}
Timber.e(e, "Encountered invalid setting while importing account \"%s\", reason: \"%s\"",
account.name, reason);
erroneousAccounts.add(new AccountDescription(account.name, account.uuid)); erroneousAccounts.add(new AccountDescription(account.name, account.uuid));
} catch (Exception e) { } catch (Exception e) {
@ -363,7 +367,7 @@ public class SettingsImporter {
if (account.incoming == null) { if (account.incoming == null) {
// We don't import accounts without incoming server settings // We don't import accounts without incoming server settings
throw new InvalidSettingValueException(); throw new InvalidSettingValueException("Missing incoming server settings");
} }
// Write incoming server settings // Write incoming server settings
@ -380,7 +384,7 @@ public class SettingsImporter {
boolean authorizationNeeded = incoming.authenticationType == AuthType.XOAUTH2; boolean authorizationNeeded = incoming.authenticationType == AuthType.XOAUTH2;
if (account.outgoing == null) { if (account.outgoing == null) {
throw new InvalidSettingValueException(); throw new InvalidSettingValueException("Missing outgoing server settings");
} }
String outgoingServerName = null; String outgoingServerName = null;
@ -448,7 +452,7 @@ public class SettingsImporter {
importIdentities(editor, contentVersion, uuid, account, overwrite, existingAccount, prefs); importIdentities(editor, contentVersion, uuid, account, overwrite, existingAccount, prefs);
} else if (!mergeImportedAccount) { } else if (!mergeImportedAccount) {
// Require accounts to at least have one identity // Require accounts to at least have one identity
throw new InvalidSettingValueException(); throw new InvalidSettingValueException("Missing identities, there should be at least one.");
} }
// Write folder settings // Write folder settings
@ -541,7 +545,7 @@ public class SettingsImporter {
// Validate email address // Validate email address
if (!IdentitySettingsDescriptions.isEmailAddressValid(identity.email)) { if (!IdentitySettingsDescriptions.isEmailAddressValid(identity.email)) {
throw new InvalidSettingValueException(); throw new InvalidSettingValueException("Invalid email address: " + identity.email);
} }
// Write email address // Write email address