mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Log Exceptions to logfile instead of STDERR
This commit is contained in:
parent
3fc19f92b8
commit
cbfa35ec18
6 changed files with 14 additions and 27 deletions
|
@ -54,8 +54,7 @@ public class FrameRateTimer implements Timer, Runnable {
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
log.error(t.getMessage());
|
log.error("exception in FrameRateTimer", t);
|
||||||
t.printStackTrace();
|
|
||||||
stop();
|
stop();
|
||||||
throw t;
|
throw t;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,8 +93,7 @@ public class UserThread {
|
||||||
return timerClass.getDeclaredConstructor().newInstance();
|
return timerClass.getDeclaredConstructor().newInstance();
|
||||||
} catch (InstantiationException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
} catch (InstantiationException | NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
||||||
String message = "Could not instantiate timer bsTimerClass=" + timerClass;
|
String message = "Could not instantiate timer bsTimerClass=" + timerClass;
|
||||||
log.error(message);
|
log.error(message, e);
|
||||||
e.printStackTrace();
|
|
||||||
throw new RuntimeException(message);
|
throw new RuntimeException(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,8 +70,7 @@ public class Encryption {
|
||||||
log.trace("Generate msgEncryptionKeyPair needed {} ms", System.currentTimeMillis() - ts);
|
log.trace("Generate msgEncryptionKeyPair needed {} ms", System.currentTimeMillis() - ts);
|
||||||
return keyPair;
|
return keyPair;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.error(e.toString());
|
log.error("Could not create key.", e);
|
||||||
e.printStackTrace();
|
|
||||||
throw new RuntimeException("Could not create key.");
|
throw new RuntimeException("Could not create key.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,7 +86,7 @@ public class Encryption {
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
|
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
|
||||||
return cipher.doFinal(payload);
|
return cipher.doFinal(payload);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
log.error("error in encrypt", e);
|
||||||
throw new CryptoException(e);
|
throw new CryptoException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,8 +127,7 @@ public class Encryption {
|
||||||
outputStream.flush();
|
outputStream.flush();
|
||||||
payloadWithHmac = outputStream.toByteArray().clone();
|
payloadWithHmac = outputStream.toByteArray().clone();
|
||||||
} catch (IOException | NoSuchProviderException e) {
|
} catch (IOException | NoSuchProviderException e) {
|
||||||
log.error(e.toString());
|
log.error("Could not create hmac", e);
|
||||||
e.printStackTrace();
|
|
||||||
throw new RuntimeException("Could not create hmac");
|
throw new RuntimeException("Could not create hmac");
|
||||||
} finally {
|
} finally {
|
||||||
if (outputStream != null) {
|
if (outputStream != null) {
|
||||||
|
@ -140,8 +138,7 @@ public class Encryption {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.error(e.toString());
|
log.error("Could not create hmac", e);
|
||||||
e.printStackTrace();
|
|
||||||
throw new RuntimeException("Could not create hmac");
|
throw new RuntimeException("Could not create hmac");
|
||||||
}
|
}
|
||||||
return payloadWithHmac;
|
return payloadWithHmac;
|
||||||
|
@ -153,8 +150,7 @@ public class Encryption {
|
||||||
byte[] hmacTest = getHmac(message, secretKey);
|
byte[] hmacTest = getHmac(message, secretKey);
|
||||||
return Arrays.equals(hmacTest, hmac);
|
return Arrays.equals(hmacTest, hmac);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.error(e.toString());
|
log.error("Could not create cipher", e);
|
||||||
e.printStackTrace();
|
|
||||||
throw new RuntimeException("Could not create cipher");
|
throw new RuntimeException("Could not create cipher");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,7 +200,7 @@ public class Encryption {
|
||||||
cipher.init(Cipher.WRAP_MODE, publicKey, oaepParameterSpec);
|
cipher.init(Cipher.WRAP_MODE, publicKey, oaepParameterSpec);
|
||||||
return cipher.wrap(secretKey);
|
return cipher.wrap(secretKey);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
log.error("Couldn't encrypt payload", e);
|
||||||
throw new CryptoException("Couldn't encrypt payload");
|
throw new CryptoException("Couldn't encrypt payload");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -233,8 +229,7 @@ public class Encryption {
|
||||||
keyPairGenerator.init(bits);
|
keyPairGenerator.init(bits);
|
||||||
return keyPairGenerator.generateKey();
|
return keyPairGenerator.generateKey();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
log.error("Couldn't generate key", e);
|
||||||
log.error(e.getMessage());
|
|
||||||
throw new RuntimeException("Couldn't generate key");
|
throw new RuntimeException("Couldn't generate key");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,7 +247,6 @@ public class Encryption {
|
||||||
return KeyFactory.getInstance(Encryption.ASYM_KEY_ALGO).generatePublic(new X509EncodedKeySpec(encryptionPubKeyBytes));
|
return KeyFactory.getInstance(Encryption.ASYM_KEY_ALGO).generatePublic(new X509EncodedKeySpec(encryptionPubKeyBytes));
|
||||||
} catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
|
} catch (InvalidKeySpecException | NoSuchAlgorithmException e) {
|
||||||
log.error("Error creating sigPublicKey from bytes. sigPublicKeyBytes as hex={}, error={}", Utilities.bytesAsHexString(encryptionPubKeyBytes), e);
|
log.error("Error creating sigPublicKey from bytes. sigPublicKeyBytes as hex={}, error={}", Utilities.bytesAsHexString(encryptionPubKeyBytes), e);
|
||||||
e.printStackTrace();
|
|
||||||
throw new KeyConversionException(e);
|
throw new KeyConversionException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,7 @@ public class Hash {
|
||||||
digest.update(data, 0, data.length);
|
digest.update(data, 0, data.length);
|
||||||
return digest.digest();
|
return digest.digest();
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
log.error("Could not create MessageDigest for hash. " + e.toString());
|
log.error("Could not create MessageDigest for hash. ", e);
|
||||||
e.printStackTrace();
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,8 +136,7 @@ public class KeyStorage {
|
||||||
PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(encodedPrivateKey);
|
PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(encodedPrivateKey);
|
||||||
privateKey = keyFactory.generatePrivate(privateKeySpec);
|
privateKey = keyFactory.generatePrivate(privateKeySpec);
|
||||||
} catch (InvalidKeySpecException | IOException e) {
|
} catch (InvalidKeySpecException | IOException e) {
|
||||||
log.error(e.getMessage());
|
log.error("Could not load key " + keyEntry.toString(), e.getMessage());
|
||||||
e.printStackTrace();
|
|
||||||
throw new RuntimeException("Could not load key " + keyEntry.toString(), e);
|
throw new RuntimeException("Could not load key " + keyEntry.toString(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,8 +160,7 @@ public class KeyStorage {
|
||||||
log.debug("load completed in {} msec", System.currentTimeMillis() - new Date().getTime());
|
log.debug("load completed in {} msec", System.currentTimeMillis() - new Date().getTime());
|
||||||
return new KeyPair(publicKey, privateKey);
|
return new KeyPair(publicKey, privateKey);
|
||||||
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
|
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
|
||||||
e.printStackTrace();
|
log.error("Could not load key " + keyEntry.toString(), e);
|
||||||
log.error(e.getMessage());
|
|
||||||
throw new RuntimeException("Could not load key " + keyEntry.toString(), e);
|
throw new RuntimeException("Could not load key " + keyEntry.toString(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,8 +179,7 @@ public class KeyStorage {
|
||||||
try (FileOutputStream fos = new FileOutputStream(storageDir + "/" + name + ".key")) {
|
try (FileOutputStream fos = new FileOutputStream(storageDir + "/" + name + ".key")) {
|
||||||
fos.write(pkcs8EncodedKeySpec.getEncoded());
|
fos.write(pkcs8EncodedKeySpec.getEncoded());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error(e.toString());
|
log.error("Could not save key " + name, e);
|
||||||
e.printStackTrace();
|
|
||||||
throw new RuntimeException("Could not save key " + name, e);
|
throw new RuntimeException("Could not save key " + name, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,7 @@ public class Sig {
|
||||||
log.trace("Generate msgSignatureKeyPair needed {} ms", System.currentTimeMillis() - ts);
|
log.trace("Generate msgSignatureKeyPair needed {} ms", System.currentTimeMillis() - ts);
|
||||||
return keyPair;
|
return keyPair;
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
e.printStackTrace();
|
log.error("Could not create key.", e);
|
||||||
log.error(e.toString());
|
|
||||||
throw new RuntimeException("Could not create key.");
|
throw new RuntimeException("Could not create key.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue