Either it's very cunning...



  •  Presented with only minor anonymizing changes:

        catch (com.yoyodyne.gnomovision.IOException e) {
            if (( e.toString().indexOf("net.rim.device.api.io.ConnectiondException") != -1 ) ||
                ( e.toString().indexOf("java.io.IOException") != -1 ) ) {
                //if the above string appears we know the client closed
                //the connection as opposed to a timeout. No point
                //calling disconnectClient();

                running = false;
                return;
            }
        }

    I can only surmise that for some reason, the original author actually wanted the misspelling of ConnectionException to remain uncaught at compile time, hence his decision to identify exceptions based on their string names rather than by specifying them in the catch clause as anyone with any sense would.

    And of course there must be some guarantee that no other types of IOException need to be handled, right?

    Either it's very cunning, or it's a joke. It made me laugh, anyway.




  • No, he intentionally didn't put them in the catch clause; the exception that actually gets thrown to his code is a Gnomovision exception that wraps the exceptions he's checking for, not those actual exceptions. Don't you just love матрёшка dolls?

    TRWTF is that either he or Yoyodyne doesn't know what getCause() is, so he uses toString() which calls getLocalizedMessage() which calls getMessage() which calls fillInStackTrace() which calls getCause() to get that information instead.



  • "net.rim" indicates a Blackberry exception.

    As it turns out (to my knowledge), you can't wrap exceptions in a Blackberry app (there is no constructor to allow it in the Exception class). It would help if we had a little more context. Either way, we can end up in a situation with the exception being silently ignored, which is almost always a bad thing.



  • @joeshmo21 said:

    you can't wrap exceptions in a Blackberry app
    !
    Um, wow. So Yoyodyne is toString()ing the real exception just to put in their pretty little box's description. For the love of GOD when will people learn that "throw;" is legal???



  • What I meant by "You can't wrap" is that the Exception constructor can't take another Throwable as an argument. I believe that Yoyodyne is taking the original exception, calling toString(), possibly appending some text, and using that to construct their own exception object. This code appears to be parsing the text of that exception to figure out what went wrong. In reality, they need to create separate exception classes. Then again, without more context, I'm just not sure what they are trying to accomplish. Seems very hackish...



  • @joeshmo21 said:

    Then again, without more context, I'm just not sure what they are trying to accomplish. Seems very hackish...

    That's exactly how I feel about most of this code, and I've got all the context you could possibly ask for!

     



  •  @joeshmo21 said:

    What I meant by "You can't wrap" is that the Exception constructor can't take another Throwable as an argument.
    Which probably means that Blackberry is J2SE 1.3 only



  • @FILE_NOT_FOUND said:

    Which probably means that Blackberry is J2SE 1.3 only

     

     

    Blackberries are Java ME (plus some proprietary APIs), and the latest ME spec is based off a stripped-down 1.3


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.