diff options
author | James Ahlborn <jtahlborn@yahoo.com> | 2012-02-06 23:52:22 +0000 |
---|---|---|
committer | James Ahlborn <jtahlborn@yahoo.com> | 2012-02-06 23:52:22 +0000 |
commit | e5a045f24eab4a8010eb13ad6f6257e644e87324 (patch) | |
tree | af06e6f3aaaba9ee81df4caf3ce928aaa6da004b | |
parent | e2c2b16bdd8cea89b3d93ce8f9cf623f56719867 (diff) | |
download | jackcess-e5a045f24eab4a8010eb13ad6f6257e644e87324.tar.gz jackcess-e5a045f24eab4a8010eb13ad6f6257e644e87324.zip |
better exception message for decimal conversion failures
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@612 f203690c-595d-4dc9-a70b-905162fa7fd2
-rw-r--r-- | src/java/com/healthmarketscience/jackcess/Column.java | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/java/com/healthmarketscience/jackcess/Column.java b/src/java/com/healthmarketscience/jackcess/Column.java index ce6050d..6023c26 100644 --- a/src/java/com/healthmarketscience/jackcess/Column.java +++ b/src/java/com/healthmarketscience/jackcess/Column.java @@ -985,8 +985,10 @@ public class Column implements Comparable<Column> { private static void writeCurrencyValue(ByteBuffer buffer, Object value) throws IOException { + Object inValue = value; try { BigDecimal decVal = toBigDecimal(value); + inValue = decVal; // adjust scale (will cause the an ArithmeticException if number has too // many decimal places) @@ -997,7 +999,8 @@ public class Column implements Comparable<Column> { buffer.putLong(decVal.movePointRight(4).longValueExact()); } catch(ArithmeticException e) { throw (IOException) - new IOException("Currency value out of range").initCause(e); + new IOException("Currency value '" + inValue + "' out of range") + .initCause(e); } } @@ -1028,8 +1031,10 @@ public class Column implements Comparable<Column> { private void writeNumericValue(ByteBuffer buffer, Object value) throws IOException { + Object inValue = value; try { BigDecimal decVal = toBigDecimal(value); + inValue = decVal; boolean negative = (decVal.compareTo(BigDecimal.ZERO) < 0); if(negative) { @@ -1069,7 +1074,8 @@ public class Column implements Comparable<Column> { buffer.put(intValBytes); } catch(ArithmeticException e) { throw (IOException) - new IOException("Numeric value out of range").initCause(e); + new IOException("Numeric value '" + inValue + "' out of range") + .initCause(e); } } |