controlling if exceptions are swallowed by a static boolean

Posted by sandis on Stack Overflow See other posts from Stack Overflow or by sandis
Published on 2010-03-19T15:42:09Z Indexed on 2010/03/20 20:41 UTC
Read the original article Hit count: 349

So we are a few guys developing this product that is communicating with a really unstable server. It often returns very strange and corrupt data. During testing we want the resulting crashes to be loud, so we discover them. But every other day we need to demonstrate our product for a potential customer. To the customer the errors will go undiscovered if we just swallow them. I am thinking about implementing something like this around all server communication to quickly switch between swallowing exceptions and crashing:

try {
    apiCall();
} catch (Exception e) {
    if(!SWALLOW_EXCEPTION) {
        throw e;
    }
}

Is this an awesome idea, or can it be done in a better way?

© Stack Overflow or respective owner

Related posts about java

Related posts about best-practices