mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-09-23 06:24:41 -04:00
Add null checks
This commit is contained in:
parent
9c8b76d2b6
commit
0687fc2f9b
1 changed files with 16 additions and 7 deletions
|
@ -128,6 +128,7 @@ public class BSFormatter {
|
||||||
try {
|
try {
|
||||||
return coinFormat.noCode().format(coin).toString();
|
return coinFormat.noCode().format(coin).toString();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
if (coin != null)
|
||||||
log.warn("Exception at formatBtc: " + t.toString());
|
log.warn("Exception at formatBtc: " + t.toString());
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -144,6 +145,7 @@ public class BSFormatter {
|
||||||
// pre and post fixing
|
// pre and post fixing
|
||||||
return coinFormat.postfixCode().format(coin).toString();
|
return coinFormat.postfixCode().format(coin).toString();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
if (coin != null)
|
||||||
log.warn("Exception at formatBtcWithCode: " + t.toString());
|
log.warn("Exception at formatBtcWithCode: " + t.toString());
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -158,6 +160,7 @@ public class BSFormatter {
|
||||||
try {
|
try {
|
||||||
return coinFormat.parse(cleanInput(input));
|
return coinFormat.parse(cleanInput(input));
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
if (input != null && input.length() > 0)
|
||||||
log.warn("Exception at parseToBtc: " + t.toString());
|
log.warn("Exception at parseToBtc: " + t.toString());
|
||||||
return Coin.ZERO;
|
return Coin.ZERO;
|
||||||
}
|
}
|
||||||
|
@ -181,6 +184,7 @@ public class BSFormatter {
|
||||||
return Coin.valueOf(new BigDecimal(parseToCoin(cleanInput(input)).value).setScale(-scale - 1,
|
return Coin.valueOf(new BigDecimal(parseToCoin(cleanInput(input)).value).setScale(-scale - 1,
|
||||||
BigDecimal.ROUND_HALF_UP).setScale(scale + 1).toBigInteger().longValue());
|
BigDecimal.ROUND_HALF_UP).setScale(scale + 1).toBigInteger().longValue());
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
if (input != null && input.length() > 0)
|
||||||
log.warn("Exception at parseToCoinWith4Decimals: " + t.toString());
|
log.warn("Exception at parseToCoinWith4Decimals: " + t.toString());
|
||||||
return Coin.ZERO;
|
return Coin.ZERO;
|
||||||
}
|
}
|
||||||
|
@ -210,6 +214,7 @@ public class BSFormatter {
|
||||||
try {
|
try {
|
||||||
return fiatFormat.noCode().format(fiat).toString();
|
return fiatFormat.noCode().format(fiat).toString();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
if (fiat != null)
|
||||||
log.warn("Exception at formatFiat: " + t.toString());
|
log.warn("Exception at formatFiat: " + t.toString());
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -224,6 +229,7 @@ public class BSFormatter {
|
||||||
try {
|
try {
|
||||||
return fiatFormat.postfixCode().format(fiat).toString();
|
return fiatFormat.postfixCode().format(fiat).toString();
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
if (fiat != null)
|
||||||
log.warn("Exception at formatFiatWithCode: " + t.toString());
|
log.warn("Exception at formatFiatWithCode: " + t.toString());
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -238,6 +244,8 @@ public class BSFormatter {
|
||||||
try {
|
try {
|
||||||
return Fiat.parseFiat(currencyCode, cleanInput(input));
|
return Fiat.parseFiat(currencyCode, cleanInput(input));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
if (input != null && input.length() > 0)
|
||||||
|
log.warn("Exception at parseToFiat: " + e.toString());
|
||||||
return Fiat.valueOf(currencyCode, 0);
|
return Fiat.valueOf(currencyCode, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,6 +269,7 @@ public class BSFormatter {
|
||||||
try {
|
try {
|
||||||
return parseToFiat(new BigDecimal(cleanInput(input)).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
return parseToFiat(new BigDecimal(cleanInput(input)).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
if (input != null && input.length() > 0)
|
||||||
log.warn("Exception at parseCoinTo4Decimals: " + t.toString());
|
log.warn("Exception at parseCoinTo4Decimals: " + t.toString());
|
||||||
return Fiat.valueOf(currencyCode, 0);
|
return Fiat.valueOf(currencyCode, 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue