wordinator
wordinator copied to clipboard
Implement own exception type for reporting errors?
At the moment errors are reported to the user like this:
+ 2023-01-27 11:59:54,997 [ERROR] RuntimeException: RuntimeException: -x (transform) parameter not specified. If the input is a _Book.xml file, you must specify the -x parameter
It's not really great that user errors are presented as log messages instead of going to stderr and being clearly labeled as user-friendly error messages the user needs to deal with. The RuntimeException: RuntimeException: is also not great.
A good mechanism for letting the detail Java code report errors up to the MakeDocx CLI driver would be to define a WordinatorException for wordinator errors, and throw that in cases like the error above. MakeDocx would then be able to report these nicely to the user, and also to correctly stop processing (with shell error codes etc).
If this sounds like a good idea I'll be happy to make a PR and start converting at least some of the code to this method.
I see now that the type seems to exist (DocxGenerationException), and it seems to be thrown in some cases in the way that I expected, but it's not caught and handled explicitly in MakeDocx. Wouldn't it be nicer if the code used this exception consistently for internal errors, and had a special case handler in MakeDocx that prints a nice error message and then quits with System.exit(1)?
And I guess it should be declared a RuntimeException so that it doesn't have to be explicitly declared in the throws everywhere.
This sounds like a good idea. Please pursue it if you'd like.
Wordinator was originally developed very quickly to meet an immediate and largely unplanned customer requirement. Once my engagement with that customer ended my ability to attend to Wordinator has been limited to a few small engagements. So the engineering quality is not necessarily what it would be if this had been a more considered activity with a little funding behind it.
Since I started at ServiceNow in 2021 my time to devote to Wordinator is very limited.
So I am very grateful for your efforts here and encourage you to improve things as you see fit.
Thanks, Eliot. I'll do this and a couple of other things as soon as I have time.