Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeException thrown instead of MrzParseException #22

Open
GoUpNorth opened this issue Nov 6, 2017 · 1 comment
Open

RuntimeException thrown instead of MrzParseException #22

GoUpNorth opened this issue Nov 6, 2017 · 1 comment
Labels

Comments

@GoUpNorth
Copy link
Contributor

I noticed that RuntimeExceptions are thrown instead of MrzParseExceptions, in 3 different places in the library:

  • MrzParser line 249
    private static int getCharacterValue(char c) { if (c == FILLER) { return 0; } if (c >= '0' && c <= '9') { return c - '0'; } if (c >= 'A' && c <= 'Z') { return c - 'A' + 10; } throw new RuntimeException("Invalid character in MRZ record: " + c); }
  • MrzFormat line 144
    public final MrzRecord newRecord() { try { return recordClass.newInstance(); } catch (Exception ex) { throw new RuntimeException(ex); } }
  • MrzSex line 50
    public static MrzSex fromMrz(char sex) { switch (sex) { case 'M': return Male; case 'F': return Female; case '<': case 'X': return Unspecified; default: throw new RuntimeException("Invalid MRZ sex character: " + sex); } }

It looks like a bug to me. Shouldn't a MrzParseException be thrown in those cases ?

Regards,
P-A

@ZsBT
Copy link
Owner

ZsBT commented Nov 7, 2017

Yes, indeed. Those are more like parse than runtime exceptions.

@ZsBT ZsBT added the bug label Nov 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants