codeforamerica / pdfparser

A command line utility written in Java for working with PDF forms
11 stars 6 forks source link

Don't swallow exceptions in JsonToPdfWriter and PdfToJsonConverter #5

Open eplusminus opened 8 years ago

eplusminus commented 8 years ago

Currently, if IText or something else throws an exception within those classes, we're doing this...

catch (IOException | DocumentException e) {
    System.out.println(e.getMessage());
    e.printStackTrace();
}

...and then just returning as if nothing happened. This means that if someone else wants to call these methods from Java code, it's impossible for them to tell if something failed (also, they may not want the stacktrace to be printed to the console). It'd be better to let those exceptions be thrown back to the caller, and let the caller decide what to do.

rogerawad commented 8 years ago

I'm hesitant about bubbling the exception all the way up to the user of the library. This will complicate their code and makes it tightly coupled to a specific implementation. I'll hold off on changing this for now.

bengolder commented 8 years ago

I think it would be useful to bubble exceptions. There's some things I would expect it to be pretty forgiving with, but I would definitely want to know if it's having trouble.

For example,