Does this count as a WTF?



  • try{

     //snip

     }

     catch (Exception ex) {

    MessageBox.Show(String.Format("There was an error trying to load the image.\n{0}", ex.Message));

     }

     catch {

     MessageBox.Show("BOOM");

    }



  • This forum is the Real WTF?



  • @campkev said:

    <font size="2" face="Lucida Console"></P>
    <P>try{</P>
    <P>&nbsp;//snip</P>
    <P>&nbsp;}</P>
    <P>&nbsp;catch (Exception ex) { </P>
    <P>MessageBox.Show(String.Format("There was an error trying to load the image.
    {0}", ex.Message));</P>
    <P>&nbsp;}</P>
    <P>&nbsp;catch {</P>
    <P>&nbsp;MessageBox.Show("BOOM"); </P>
    <P>}</P>
    <P>&nbsp;</font>

    k, I think I get the gist of it.  If the image doesn't display, a messagebox pops up explaining why.

    If I'm right, this is a WTF.  Not displaying an image on a page is something that should fail pretty silently for users.  For developers and QA, maybe not so much.



  • Sooo...

    If the try block fails, but doesn't actually throw any kind of exception whatsoever, it goes 'BOOM'?

    Maybe they intended (once upon a time) to write different catch blocks for different classes of exception, and the BOOM is a sort of failsafe fail.

    But (Exception ex) is just the general class, so everything goes to the first block (if it fails at all of course.)

    Minor WTF in that the code will never execute, but given the code ('BOOM!') it's better that way...



  • @BlueKnot said:

    If the try block fails, but doesn't actually throw any kind of exception
    whatsoever, it goes 'BOOM'?

    AFAIK, a parameterless catch block handles exceptions that are not derived from System.Exception.



  •  java.lang.Throwable



  • @Spectre said:

    @BlueKnot said:
    If the try block fails, but doesn't actually throw any kind of exception whatsoever, it goes 'BOOM'?
    AFAIK, a parameterless catch block handles exceptions that are not derived from System.Exception.

     

    and in C# those would be...?



  • Well, yes, it's a WTF.

    1. It's written in D flat, apparently.(1)
    2. It uses exceptions. They suck.(2)
    3. It gives absolutely no information about any error which doesn't match the first condition. We've seen these sorts of applications reported many times in Error'd.

    (1). All programming languages suck. Some suck more than others. I don't personally know D flat, but several of the languages it's inspired by suck surprising hard. And, I've yet to see a D flat code example that looks more legible than, say, C++. Not that I do much programming in C++ - it's just a related language which does not seem to me to suck quite as much.

    (2). I actually like the idea of programs handling unusual situations gracefully. The problem I have with 'exception handling' is that it's usually used to refer to the 'try/catch' hack used in Java and related languages, which generally doesn't handle unusual situations gracefully at all, and degrades performance to boot. It is, admittedly, much easier to code than actually checking before you do something to see if it will work, and checking the return code of every function you call to see if it performed as expected.



  • @campkev said:

    @Spectre said:

    @BlueKnot said:
    If the try block fails, but doesn't actually throw any kind of exception whatsoever, it goes 'BOOM'?
    AFAIK, a parameterless catch block handles exceptions that are not derived from System.Exception.

     

    and in C# those would be...?

    AFAIK, CLR allows you to throw around anything you please.



  • @Spectre said:

    @campkev said:

    @Spectre said:

    @BlueKnot said:
    If the try block fails, but doesn't actually throw any kind of exception whatsoever, it goes 'BOOM'?
    AFAIK, a parameterless catch block handles exceptions that are not derived from System.Exception.

     

    and in C# those would be...?

    AFAIK, CLR allows you to throw around anything you please.

     

    Hmm, I don't think so, but the warning that this code produces makes me think it might be possible.  Nevertheless, the code in the OP should produce the following compiler warning:

    A previous catch clause already catches all exceptions. All non-exceptions thrown will be wrapped in a System.Runtime.CompilerServices.RuntimeWrappedException     



  •  Would the second catch handle an exception that was thrown by MessageBow.Show? (ex.Message is null, for example)



  • @tgape said:

    (1). All programming languages suck.

     

     

    Yeah, real programmers write their programs with a hex editor directly on the executable file.

     

    Mahoro



  • @mahoromhr said:

    @tgape said:

    (1). All programming languages suck.

     

    Yeah, real programmers write their programs with a hex editor directly on the executable file.

    Mahoro

     

    You've got hex? I have to toggle them in with a single switch. 



  • @trainbrain27 said:

    @mahoromhr said:

    @tgape said:

    (1). All programming languages suck.

     

    Yeah, real programmers write their programs with a hex editor directly on the executable file.

    Mahoro

     

    You've got hex? I have to toggle them in with a single switch. 

    Switches? Man, I'd be glad if we had switches. We have to use three magnets, a needle and a magnifying glass to code.



  •  @vt_mruhlin said:

     Would the second catch handle an exception that was thrown by MessageBow.Show? (ex.Message is null, for example)

    I guess you'd have to add a second try block. like that:

    try {}

    catch(Exception ex) {

    try{ //messagebox  }

    catch { // messagebox failed }

    }

      Funny. %)



  • @tgape said:

    The problem I have with 'exception handling' is that it's usually used to refer to the 'try/catch' hack used in Java and related languages, which generally doesn't handle unusual situations gracefully at all, and degrades performance to boot.

    Dwarf-2 EH imposes no time costs except the processing of any exceptions that are actually thrown.



  • @Ren said:

    @trainbrain27 said:

    @mahoromhr said:

    @tgape said:

    (1). All programming languages suck.

     

    Yeah, real programmers write their programs with a hex editor directly on the executable file.

    Mahoro

     

    You've got hex? I have to toggle them in with a single switch. 

    Switches? Man, I'd be glad if we had switches. We have to use three magnets, a needle and a magnifying glass to code.

     

    Real programmers use butterflies! When I let them flap their wings, they create disturbances in the upper atmosphere that focuses cosmic rays to strike the disc platter and flip the desired bit



  •  @Ren said:

    @trainbrain27 said:

    @mahoromhr said:

    @tgape said:

    (1). All programming languages suck.

     

    Yeah, real programmers write their programs with a hex editor directly on the executable file.

    Mahoro

     

    You've got hex? I have to toggle them in with a single switch. 

    Switches? Man, I'd be glad if we had switches. We have to use three magnets, a needle and a magnifying glass to code.

     You have zero's and one's? I only have zero's! I once wrote a whole database with only zero's...



  • @bjolling said:

    Real programmers use butterflies! When I let them flap their wings, they create disturbances in the upper atmosphere that focuses cosmic rays to strike the disc platter and flip the desired bit
    xkcd quote detected!  Please report to Room 101 for reeducation.



  • @bstorer said:

    @bjolling said:

    Real programmers use butterflies! When I let them flap their wings, they create disturbances in the upper atmosphere that focuses cosmic rays to strike the disc platter and flip the desired bit
    xkcd quote detected!  Please report to Room 101 for reeducation.

     

    Don't be so harsh just yet. I think the MoL will be able to handle him without such resources. I mean, he didn't provide a link or anything!



  • @dtech said:

    You have zero's and one's? I only have zero's! I once wrote a whole database
    with only zero's...

    That's nothing. I once wrote a whole sentence without any apostrophes!



  • @Spectre said:

    @dtech said:
    You have zero's and one's? I only have zero's! I once wrote a whole database
    with only zero's...

    That's nothing. I once wrote a whole sentence without any apostrophes!

    That's amazing!  You're some kind of wizard!  HE'S A WIZARD!  LET'S GET HIM!



  • @bstorer said:

    @Spectre said:

    @dtech said:
    You have zero's and one's? I only have zero's! I once wrote a whole database
    with only zero's...

    That's nothing. I once wrote a whole sentence without any apostrophes!

    That is amazing!  You are some kind of wizard!  HE IS A WIZARD!  LET US GET HIM!

    FTFY



  • @dtech said:

     @Ren said:

    @trainbrain27 said:

    @mahoromhr said:

    @tgape said:

    (1). All programming languages suck.

     

    Yeah, real programmers write their programs with a hex editor directly on the executable file.

    Mahoro

     

    You've got hex? I have to toggle them in with a single switch. 

    Switches? Man, I'd be glad if we had switches. We have to use three magnets, a needle and a magnifying glass to code.

     You have zero's and one's? I only have zero's! I once wrote a whole database with only zero's...

    Sigh. What the above four programmers(1) apparently don't recognize is that they're all talking about programming languages - which, of course, suck.

    Even the butterflies are yet another programming language. It's just that most of us draw the line at some point, due to the extreme suck factor.

    (1) Or, depending upon how one counts, five.



  • @tgape said:

    Sigh. What the above four programmers(1) apparently don't recognize is that they're all talking about programming languages - which, of course, suck.

    Even the butterflies are yet another programming language. It's just that most of us draw the line at some point, due to the extreme suck factor.

    (1) Or, depending upon how one counts, five.

    I tried to get around that problem by coding in something that wasn't a programming language but I couldn't get it to compile...




  • @fyjham said:

    I tried to get around that problem by coding in something that wasn't a programming language but I couldn't get it to compile...
     

    import human.language.english.*

    Do what I want



  • @dtech said:

    @fyjham said:

    I tried to get around that problem by coding in something that wasn't a programming language but I couldn't get it to compile...
     

    import human.language.english.*
    

    Do what I want

     

    $ dwiw
    dwiw: 1.riadok: CHYBA: human.language.english.*: nič nebolo vyhľadané
    dwiw: 3.riadok: CHYBA: slovo nepoznané: what
    dwiw: 3.riadok: upozornenie: prepozície požiada 2.gramatický pád: do
    dwiw: 3.riadok: CHYBA: slovo nepoznané: want
    $ sudwiw
    sudwiw: Čo do p..e chceš?
    $ _

    Now what do you do?



  • @dtech said:

    @bstorer said:

    @bjolling said:

    Real programmers use butterflies! When I let them flap their wings, they create disturbances in the upper atmosphere that focuses cosmic rays to strike the disc platter and flip the desired bit
    xkcd quote detected!  Please report to Room 101 for reeducation.

     

    Don't be so harsh just yet. I think the MoL will be able to handle him without such resources. I mean, he didn't provide a link or anything!

    I will do a better job disguising the xkcd reference next time.



  •  @The General said:

    $ dwiw
    dwiw: 1.riadok: CHYBA: human.language.english.*: nič nebolo vyhľadané
    dwiw: 3.riadok: CHYBA: slovo nepoznané: what
    dwiw: 3.riadok: upozornenie: prepozície požiada 2.gramatický pád: do
    dwiw: 3.riadok: CHYBA: slovo nepoznané: want
    $ sudwiw
    sudwiw: Čo do p..e chceš?
    $ _

    Now what do you do?

    Silly me, I forgot a few things, this should work:

    import human.language.english.*
    import human.interface.mindreader.*
    

    Mindreader mr = new Mindreader(System.Controller.Mind);

    using mr
    {
    understand("Do what " + System.Controller + " wants");
    }

    Please notice that this program makes all other software redundant, since this one will do anything a users could possibly want.



  • Error compiling dwiw:

     dwiw.source:4 BC30389 "System.Controller.Mind" is not accessible in ths context because it is "Private".

    Build failed, 1 error, 0 warnings.



  • @Spectre said:

    @campkev said:

    @Spectre said:

    @BlueKnot said:
    If the try block fails, but doesn't actually throw any kind of exception whatsoever, it goes 'BOOM'?
    AFAIK, a parameterless catch block handles exceptions that are not derived from System.Exception.

     

    and in C# those would be...?

    AFAIK, CLR allows you to throw around anything you please.

    Oh, did Ballmer ask for this "feature"?

    throw chair;

    throw desk;

    throw table;

    // and, when you've been drinking too much

    throw up;

    (somehow, I don't think I'd like to catch that last one...)



  •  I hope you didn't want to say: ClaudeSuck, too.

     



  • @dtech said:

     @The General said:

    $ dwiw
    dwiw: 1.riadok: CHYBA: human.language.english.*: nič nebolo vyhľadané
    dwiw: 3.riadok: CHYBA: slovo nepoznané: what
    dwiw: 3.riadok: upozornenie: prepozície požiada 2.gramatický pád: do
    dwiw: 3.riadok: CHYBA: slovo nepoznané: want
    $ sudwiw
    sudwiw: Čo do p..e chceš?
    $ _

    Now what do you do?

    Silly me, I forgot a few things, this should work:

    import human.language.english.*
    import human.interface.mindreader.*
    

    Mindreader mr = new Mindreader(System.Controller.Mind);

    using mr
    {
    understand("Do what " + System.Controller + " wants");
    }

    Please notice that this program makes all other software redundant, since this one will do anything a users could possibly want.

     

     

    Like pressing F7 in Word?

     



  • @dtech said:

    Silly me, I forgot a few things, this should work:

    import human.language.english.*
    import human.interface.mindreader.*

    Mindreader mr = new Mindreader(System.Controller.Mind);

    using mr
    {
    understand("Do what " + System.Controller + " wants");
    }

    Please notice that this program makes all other software redundant, since this one will do anything a users could possibly want.

     

    Considering that the the initial requirement list and rough draft of any project has had enough "inconsistencies" to make even M.C. Escher gouge his eyeballs out, this could be trickier than you think.  Without Language Suck to fight against Project Suck everything ever built would suck even that much more.



  • @BeenThere said:

    Without Language Suck to fight against Project Suck everything ever built would suck even that much more.

    Sometimes there's so much suckage, it becomes hazardous. Luckily, the developers are in the eye of the hurricane where all the suckage balances out and we just get to watch the show...


Log in to reply
 

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