XRPLF / xrpl4j

A 100% Java implementation to interact with the XRP Ledger.
ISC License
86 stars 48 forks source link

Improve error emission for `ByteUtils.padded` #499

Open sappenin opened 10 months ago

sappenin commented 10 months ago

Currently, if one tries to create a UIntType8 (or 16, 32, 64, or anything that ultimately relies on ByteUtils.java) with more than 8 bits (or 2 bytes), then the exception thrown is not helpful. E.g., this code:

new UInt8Type(UnsignedLong.valueOf(500));

yields this exception: java.lang.IllegalArgumentException: invalid count: -1

Instead, the error emission should indicate something about bit legnth. This actually can be handled by improving the error emission in ByteUtils#padded and adding better test coverage, in particular asserting on the error message here.