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

BicUtil#validate trasnlates BicFormatException with specific violation to UNKNOWN #104

Closed achrzastowski-pinecone closed 1 year ago

achrzastowski-pinecone commented 1 year ago

The problem is this line:

https://github.com/arturmkrtchyan/iban4j/blob/master/src/main/java/org/iban4j/BicUtil.java#L59

when there is a BicFormatException with specified violation, exception handling translates it to UNKNOWN. It would be good to do not translate BicFormatException then it is possible to preapare custom validation messages etc. rather than using exception message to user. Change is really simple:

.....
        } catch (UnsupportedCountryException | BicFormatException e) {
            throw e;
        } catch (RuntimeException e) {
            throw new BicFormatException(UNKNOWN, e.getMessage());
        }
.....
hajk1 commented 1 year ago

will be merged in next release