arturmkrtchyan / iban4j

A Java library for generation and validation of the International Bank Account Numbers (IBAN ISO_13616) and Business Identifier Codes (BIC ISO_9362).
http://iban4j.org
Apache License 2.0
270 stars 124 forks source link

Violation overriden to UNKNOWN in BicUtil & IbanUtil #116

Closed nbrass closed 11 months ago

nbrass commented 1 year ago

Hi, currently the Violation is overriden with value "UNKNOWN" in BicUtil.validate() & IbanUtil.validate() as BicFormatException & IbanFormatException are RuntimeExceptions and caught in the RuntimeException catch-Block.

Can you please fix this? Thanks in advance!

Best regards Norman

hajk1 commented 1 year ago

@nbrass I checked the code. It seems to need modifications. But I did not get your exact requirements. Do you expect a more meaningful "IbanFormatException" and "BicFormatException" in both methods?

nbrass commented 12 months ago

@hajk1 I would expect the violation set from the root cause. From my point of view you need to check if the RuntimeException is of type BicFormatException or IbanFormatException and in these cases rethrow it directly instead of creating a new one.

hajk1 commented 12 months ago

It makes sense, I will fix it in the next release

hajk1 commented 11 months ago

IbanUtil.validate had the desired feature, and Iban4jException covers both BicFormatException & IbanFormatException. The BicUtil.validate is now changed to have the same functionality.