fix error messages on subclassed importers/exporters

This commit is contained in:
Craig Raw 2021-06-22 10:13:37 +02:00
parent 5482196cc7
commit 4d6609990c
8 changed files with 30 additions and 27 deletions

View file

@ -57,8 +57,8 @@ public class CoboVaultSinglesig implements KeystoreFileImport, WalletImport {
return keystore; return keystore;
} catch (Exception e) { } catch (Exception e) {
log.error("Error getting Cobo Vault keystore", e); log.error("Error getting " + getName() + " keystore", e);
throw new ImportException("Error getting Cobo Vault keystore", e); throw new ImportException("Error getting " + getName() + " keystore", e);
} }
} }
@ -81,7 +81,7 @@ public class CoboVaultSinglesig implements KeystoreFileImport, WalletImport {
try { try {
wallet.checkWallet(); wallet.checkWallet();
} catch(InvalidWalletException e) { } catch(InvalidWalletException e) {
throw new ImportException("Imported Cobo Vault wallet was invalid: " + e.getMessage()); throw new ImportException("Imported " + getName() + " wallet was invalid: " + e.getMessage());
} }
return wallet; return wallet;

View file

@ -150,8 +150,8 @@ public class ColdcardMultisig implements WalletImport, KeystoreFileImport, Walle
return wallet; return wallet;
} catch(Exception e) { } catch(Exception e) {
log.error("Error importing Coldcard multisig wallet", e); log.error("Error importing " + getName() + " wallet", e);
throw new ImportException("Error importing Coldcard multisig wallet", e); throw new ImportException("Error importing " + getName() + " wallet", e);
} }
} }
@ -203,8 +203,8 @@ public class ColdcardMultisig implements WalletImport, KeystoreFileImport, Walle
writer.flush(); writer.flush();
} catch(Exception e) { } catch(Exception e) {
log.error("Error exporting Coldcard multisig wallet", e); log.error("Error exporting " + getName() + " wallet", e);
throw new ExportException("Error exporting Coldcard multisig wallet", e); throw new ExportException("Error exporting " + getName() + " wallet", e);
} }
} }

View file

@ -86,8 +86,8 @@ public class ColdcardSinglesig implements KeystoreFileImport, WalletImport {
} }
} }
} catch (Exception e) { } catch (Exception e) {
log.error("Error getting Coldcard keystore", e); log.error("Error getting " + getName() + " keystore", e);
throw new ImportException("Error getting Coldcard keystore", e); throw new ImportException("Error getting " + getName() + " keystore", e);
} }
throw new ImportException("Correct derivation not found for script type: " + scriptType); throw new ImportException("Correct derivation not found for script type: " + scriptType);

View file

@ -62,11 +62,11 @@ public class KeystoneSinglesig implements KeystoreFileImport, WalletImport {
return keystore; return keystore;
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
log.error("Error getting Keystone keystore - not an output descriptor"); log.error("Error getting " + getName() + " keystore - not an output descriptor");
throw new ImportException("Error getting Keystone keystore", e); throw new ImportException("Error getting " + getName() + " keystore", e);
} catch (Exception e) { } catch (Exception e) {
log.error("Error getting Keystone keystore", e); log.error("Error getting " + getName() + " keystore", e);
throw new ImportException("Error getting Keystone keystore", e); throw new ImportException("Error getting " + getName() + " keystore", e);
} }
} }
@ -89,7 +89,7 @@ public class KeystoneSinglesig implements KeystoreFileImport, WalletImport {
try { try {
wallet.checkWallet(); wallet.checkWallet();
} catch(InvalidWalletException e) { } catch(InvalidWalletException e) {
throw new ImportException("Imported Keystone wallet was invalid: " + e.getMessage()); throw new ImportException("Imported " + getName() + " wallet was invalid: " + e.getMessage());
} }
return wallet; return wallet;

View file

@ -46,7 +46,7 @@ public class Sparrow implements WalletImport, WalletExport {
@Override @Override
public String getWalletExportDescription() { public String getWalletExportDescription() {
return "Exports your Sparrow wallet file, which can be imported into another Sparrow instance running on any supported platform."; return "Exports your Sparrow wallet file, which can be imported into another Sparrow instance running on any supported platform. If the wallet is encrypted, the same password is used to encrypt the exported file.";
} }
@Override @Override

View file

@ -35,8 +35,8 @@ public class SpecterDIY implements KeystoreFileImport, WalletExport {
return keystore; return keystore;
} catch(IOException e) { } catch(IOException e) {
log.error("Error getting Specter DIY keystore", e); log.error("Error getting " + getName() + " keystore", e);
throw new ImportException("Error getting Specter DIY keystore", e); throw new ImportException("Error getting " + getName() + " keystore", e);
} }
} }
@ -72,8 +72,8 @@ public class SpecterDIY implements KeystoreFileImport, WalletExport {
writer.append("addwallet ").append(wallet.getName()).append("&").append(OutputDescriptor.getOutputDescriptor(wallet).toString().replace('\'', 'h')).append("\n"); writer.append("addwallet ").append(wallet.getName()).append("&").append(OutputDescriptor.getOutputDescriptor(wallet).toString().replace('\'', 'h')).append("\n");
writer.flush(); writer.flush();
} catch(Exception e) { } catch(Exception e) {
log.error("Error exporting Specter DIY wallet", e); log.error("Error exporting " + getName() + " wallet", e);
throw new ExportException("Error exporting Specter DIY wallet", e); throw new ExportException("Error exporting " + getName() + " wallet", e);
} }
} }

View file

@ -30,8 +30,8 @@ public class SpecterDesktop implements WalletImport, WalletExport {
outputStream.write(json.getBytes(StandardCharsets.UTF_8)); outputStream.write(json.getBytes(StandardCharsets.UTF_8));
outputStream.flush(); outputStream.flush();
} catch(Exception e) { } catch(Exception e) {
log.error("Error exporting Specter Desktop wallet", e); log.error("Error exporting " + getName() + " wallet", e);
throw new ExportException("Error exporting Specter Desktop wallet", e); throw new ExportException("Error exporting " + getName() + " wallet", e);
} }
} }
@ -87,17 +87,17 @@ public class SpecterDesktop implements WalletImport, WalletExport {
try { try {
wallet.checkWallet(); wallet.checkWallet();
} catch(InvalidWalletException e) { } catch(InvalidWalletException e) {
throw new ImportException("Imported Specter wallet was invalid: " + e.getMessage()); throw new ImportException("Imported " + getName() + " wallet was invalid: " + e.getMessage());
} }
return wallet; return wallet;
} }
} catch(Exception e) { } catch(Exception e) {
log.error("Error importing Specter Desktop wallet", e); log.error("Error importing " + getName() + " wallet", e);
throw new ImportException("Error importing Specter Desktop wallet", e); throw new ImportException("Error importing " + getName() + " wallet", e);
} }
throw new ImportException("File was not a valid Specter Desktop wallet"); throw new ImportException("File was not a valid " + getName() + " wallet");
} }
@Override @Override

View file

@ -161,8 +161,11 @@ public class TransactionsController extends WalletFormController implements Init
String date = LOG_DATE_FORMAT.format(new Date()); String date = LOG_DATE_FORMAT.format(new Date());
String logLine = "\n" + date + " " + logMessage; String logLine = "\n" + date + " " + logMessage;
Platform.runLater(() -> { Platform.runLater(() -> {
loadingLog.appendText(logLine); int lastLineStart = loadingLog.getText().lastIndexOf("\n");
loadingLog.setScrollLeft(0); if(lastLineStart < 0 || !loadingLog.getText().substring(lastLineStart).equals(logLine)) {
loadingLog.appendText(logLine);
loadingLog.setScrollLeft(0);
}
}); });
} }
} }