Fail fast approach for parsing errors

28 views
Skip to first unread message

Dmitriy Tserehman

unread,
Nov 19, 2013, 6:16:08 PM11/19/13
to mongee...@googlegroups.com
Hi

I've noticed you are using a graceful approach for handing error conditions in a number of places rather than just throwing an exception and having the process to abort. You can see it by searching for "log.error" in the codebase. For example, I see this:

        } catch (IOException e) {
            logger.error("IOException", e);
        } catch (org.xml.sax.SAXException e) {
            logger.error("SAXException", e);
        }

In my situation I would like to just fail-fast instead of proceeding on and trying to parse and proceed to other changeSets.

Was there a thought of either re-throwing exception after logging it or just throwing some Unchecked or other RuntimeException? May be such behavior could be also made conditional, similarly to how it is done with the "failOnError" flag in the ChangeSet?

Thanks,
Dmitriy.
Message has been deleted

David Carr

unread,
Nov 20, 2013, 7:11:37 AM11/20/13
to mongee...@googlegroups.com
I think that it may have been me that introduced this behavior. My main goal at the time was for the output to be consistently logged, rather than go to System.out/err. I'd be fine with petty much all scenarios failing fast (no config option needed). Maybe introduce a MongeezException class and throw that in the catch blocks?

Sent from Mailbox for iPhone


On Tue, Nov 19, 2013 at 6:18 PM, Dmitriy Tserehman <dmitr...@gmail.com> wrote:

Was there a thought of either re-throwing exception after logging it or just throwing some Unchecked or other RuntimeException? May be such behavior could be also made conditional, similarly to how it is done with the "failOnError" flag on the ChangeSet?

        } catch (RuntimeException e) {
            if (changeSet.isFailOnError()) {
                throw e;
            } else {
                logger.warn("ChangeSet " + changeSet.getChangeId() + " has failed, but failOnError is set to false", e.getMessage());
            }
        } 
 
Thanks,
Dmitriy.

--
You received this message because you are subscribed to the Google Groups "Mongeez Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongeez-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Dmitriy Tserehman

unread,
Nov 20, 2013, 9:04:24 PM11/20/13
to mongee...@googlegroups.com
Thanks for the reply David!

I made changes and sent a pull request for it.

Thanks,
Dmitriy.
Reply all
Reply to author
Forward
0 new messages