• (cs)

    E is for Exception and that's good enough for me. OM NOM NOM!

  • Dude (unregistered)

    I hate those pesky e's. I had to get rid of them all over my codebase too. It didn't do much for the application, but it builds a little faster now....

  • no u (unregistered)

    this is still dangerous code. To make it truly safe it needs a

     finally {} 
  • (cs) in reply to Justice
    Justice:
    E is for Exception and that's good enough for me. OM NOM NOM!

    +10. That's awesome!

  • (cs)

    All this talk about "e" is going to attract all of those discotheque-crazy Europeans from yesterday's comment thread.

  • (cs)

    It's the Bad Code Offsets you and your team buy each month that keep the Apache project running isn't it?

  • (cs)

    How about an extension method to teach these people what to do with exceptions? I use ex.Log(), which uses a static, configurable ErrorLog class to log the full stack trace and everything else to the EventLog, and emails the same to the developer.

  • (cs) in reply to no u
    no u:
    this is still dangerous code. To make it truly safe it needs a
     finally {} 
    I never knew you could combine that with catch {}. I guess you unlearn something new every day.
  • callingFoul (unregistered)

    What language is this? This wouldn't even compile in Java without the 'e'.

  • StupidTheKid (unregistered)

    Oh, how I wish this story was fake... We were asked to do the same in our codebase; to remove all compilation warnings without changing behavior.

    There is seemingly a market for software that behaves like a pack of rabid werewolves.

  • (cs)

    DoProcessReceipts() just looks like a long-ass 100+ line function that does SQL queries, array manipulation, and a ton of other operations that can be prone to all kinds of exceptions. I can't believe there isn't even a log entry for when something goes wrong.

  • (cs) in reply to hoodaticus
    hoodaticus:
    How about an extension method to teach these people what to do with exceptions? I use ex.Log(), which uses a static, configurable ErrorLog class to log the full stack trace and everything else to the EventLog, and emails the same to the developer.
    You know, it's sometimes hard to tell around here when someone is pulling your leg in the comments. So I think I'll just sit back and let this sail on by ...
  • Rawr (unregistered) in reply to callingFoul
    callingFoul:
    What language is this? This wouldn't even compile in Java without the 'e'.

    It's C#, the 'joke' is that with the e you get a warning 'Variable e is declared but never used', so they removed it.

  • The Nerve (unregistered)

    Fixed?

    try { 
        DoProcessReceipts();
    }
    catch (Exception e) { 
      // this should never happen
    }
    
  • Nagesh (unregistered)

    This is standard programming practice in Hyderabad

  • (cs) in reply to The Nerve
    The Nerve:
    Fixed?
    try { 
        DoProcessReceipts();
    }
    catch (Exception e) { 
      e.ToString();
    }
    
    FTFY
  • Britmaster (unregistered) in reply to frits
    frits:
    All this talk about "e" is going to attract all of those discotheque-crazy Europeans from yesterday's comment thread.
    You mean American Trolls masquerading as Europeans, right? Everyone in Europe is on Summer vacation for 3 months.

    TRWTF is American labour laws.

  • zunesis (unregistered) in reply to hoodaticus
    hoodaticus:
    The Nerve:
    Fixed?
    try { 
        DoProcessReceipts();
    }
    catch (Exception e) { 
      Console.WriteLine("Error");
    }
    
    FTFY
    Even better
  • zunesis (unregistered) in reply to Britmaster
    Britmaster:
    frits:
    All this talk about "e" is going to attract all of those discotheque-crazy Europeans from yesterday's comment thread.
    You mean American Trolls masquerading as Europeans, right? Everyone in Europe is on Summer vacation for 3 months.

    TRWTF is American labour laws.

    No one reads the website from home?

  • Tony Little (unregistered) in reply to callingFoul
    callingFoul:
    What language is this? This wouldn't even compile in Java without the 'e'.
    Well, you eliminated one. Keep going, you CAN DO IT! [image]
  • (cs) in reply to Britmaster
    Britmaster:
    frits:
    All this talk about "e" is going to attract all of those discotheque-crazy Europeans from yesterday's comment thread.
    You mean American Trolls masquerading as Europeans, right?
    It hardly makes a difference to me.
  • (cs) in reply to SCSimmons
    SCSimmons:
    hoodaticus:
    How about an extension method to teach these people what to do with exceptions? I use ex.Log(), which uses a static, configurable ErrorLog class to log the full stack trace and everything else to the EventLog, and emails the same to the developer.
    You know, it's sometimes hard to tell around here when someone is pulling your leg in the comments. So I think I'll just sit back and let this sail on by ...

    No, he's serious, it's just that he's been 'Enterprised' (notice the use of a configurable log provider and extension methods).

  • hoodaticus (unregistered) in reply to zunesis
    zunesis:
    hoodaticus:
    The Nerve:
    Fixed?
    try { 
        DoProcessReceipts();
    }
    catch (Exception e) { 
      Console.WriteLine("Error");
    }
    
    FTFY
    Even better
    You still get the warning that way, dummy. It should obviously be:
    try { 
        DoProcessReceipts();
    }
    catch (Exception e) { 
      MsgBox(e.ToString());
    }
    
    ...especially on a server.
  • (cs) in reply to hoodaticus
    hoodaticus:
    zunesis:
    hoodaticus:
    The Nerve:
    Fixed?
    try { 
        DoProcessReceipts();
    }
    catch (Exception e) { 
      Console.WriteLine("Error");
    }
    
    FTFY
    Even better
    You still get the warning that way, dummy. It should obviously be:
    try { 
        DoProcessReceipts();
    }
    catch (Exception e) { 
      MsgBox(e.ToString());
    }
    
    ...especially on a server.

    ... after calling office automation code! WIN!

  • zunesis (unregistered) in reply to hoodaticus
    hoodaticus:
    zunesis:
    hoodaticus:
    The Nerve:
    Fixed?
    try { 
        DoProcessReceipts();
    }
    catch (Exception e) { 
      Console.WriteLine("Error");
    }
    
    FTFY
    Even better
    You still get the warning that way, dummy. It should obviously be:
    try { 
        DoProcessReceipts();
    }
    catch (Exception e) { 
      MsgBox(e.ToString());
    }
    
    ...especially on a server.

    The idea was that you get an error message, but none of the helpful information that was in the exception. The message box on a server has been covered.

  • (cs) in reply to zunesis
    zunesis:
    Even better

    That actually is better (at least there is something being outputted as opposed to the silent scream of a caught exception), but you'll still get the compiler warning.

  • SeySayux (unregistered)

    Next time you bash e, get to know it first. Thanks.

  • Ryan (unregistered)

    Hooray for compliant code! 'Cause the non-compliant variety is just too much for me, you know.

  • (cs) in reply to C-Octothorpe
    C-Octothorpe:
    the silent scream of a caught exception

    Is that a concept from Lovecraft-Driven Development (LDD)?

    Come to think of it, the majority of code seems to be based on primal terror.

  • (cs)

    Embarassingly enough, it eluded everybody that every error and exception would endure even after eliminating the pesky "e".

  • (cs) in reply to SCSimmons
    SCSimmons:
    hoodaticus:
    How about an extension method to teach these people what to do with exceptions? I use ex.Log(), which uses a static, configurable ErrorLog class to log the full stack trace and everything else to the EventLog, and emails the same to the developer.
    You know, it's sometimes hard to tell around here when someone is pulling your leg in the comments. So I think I'll just sit back and let this sail on by ...
    At a minimum, I like to know what part of my code throws exceptions so I can fix the problem.
  • evilspoons (unregistered) in reply to boog
    boog:
    Embarassingly enough, it eluded everybody that every error and exception would endure even after eliminating the pesky "e".

    Some part of me wants to give you a high five... another part of me wants to smack you.

  • (cs) in reply to boog
    boog:
    Embarassingly enough, it eluded everybody that every error and exception would endure even after eliminating the pesky "e".

    BUT, the point was not to fix the errors/exceptions, it was simply to remove the build warnings.

  • (cs) in reply to boog
    boog:
    Embarassingly enough, it eluded everybody that every error and exception would endure even after eliminating the pesky "e".

    You mean the exception would still happen, but would still be swallowed by the empty catch, right? The way I read your comment was that it would bubble up...

  • (cs) in reply to Britmaster
    Britmaster:
    frits:
    All this talk about "e" is going to attract all of those discotheque-crazy Europeans from yesterday's comment thread.
    You mean American Trolls masquerading as Europeans, right? Everyone in Europe is on Summer vacation for 3 months.

    TRWTF is American labour laws.

    If only we had 3 monthes... in France we have only 2. CA c'est le vrai WTF.

  • Robb (unregistered)
    "As a general rule of thumb," writes Newman,

    Helloooo NEWMAN

  • (cs) in reply to C-Octothorpe
    C-Octothorpe:
    SCSimmons:
    hoodaticus:
    How about an extension method to teach these people what to do with exceptions? I use ex.Log(), which uses a static, configurable ErrorLog class to log the full stack trace and everything else to the EventLog, and emails the same to the developer.
    You know, it's sometimes hard to tell around here when someone is pulling your leg in the comments. So I think I'll just sit back and let this sail on by ...

    No, he's serious, it's just that he's been 'Enterprised' (notice the use of a configurable log provider and extension methods).

    Yeah, I'm about as enterprisey as it gets. I've discovered that my code gets more maintainable when I have proper abstraction and domain models that describe my problems. And I've never seen non-enterprisey code that can read records from a database and package them into business objects, with exception logging, in a single line.

  • (cs) in reply to C-Octothorpe
    C-Octothorpe:
    boog:
    Embarassingly enough, it eluded everybody that every error and exception would endure even after eliminating the pesky "e".

    You mean the exception would still happen, but would still be swallowed by the empty catch, right? The way I read your comment was that it would bubble up...

    I think he means that the exception wasn't actually handled. Of course, ignoring it is sometimes the answer.

    For instance, my exception logger class has an empty try catch around the Log method, "//because exception loggers should not throw exceptions".

  • (cs) in reply to hoodaticus
    hoodaticus:
    For instance, my exception logger class has an empty try catch around the Log method, "//because exception loggers should not throw exceptions".

    But... but... but... who's going to log the loggers?!

  • Big Bother (unregistered) in reply to RHuckster
    RHuckster:
    DoProcessReceipts() just looks like a long-ass 100+ line function that does SQL queries, array manipulation, and a ton of other operations that can be prone to all kinds of exceptions. I can't believe there isn't even a log entry for when something goes wrong.
    We've always been at war with Oracle.
  • blarg (unregistered)
  • zunesis (unregistered) in reply to C-Octothorpe
    C-Octothorpe:
    zunesis:
    Even better

    That actually is better (at least there is something being outputted as opposed to the silent scream of a caught exception), but you'll still get the compiler warning.

    I meant "better" as in "more ironic" but whatever.

  • callingFoul (unregistered) in reply to Rawr
    Rawr:
    callingFoul:
    What language is this? This wouldn't even compile in Java without the 'e'.

    It's C#, the 'joke' is that with the e you get a warning 'Variable e is declared but never used', so they removed it.

    And there's TRWTF - assuming developers using a language will write shite.

  • (cs) in reply to callingFoul
    callingFoul:
    Rawr:
    callingFoul:
    What language is this? This wouldn't even compile in Java without the 'e'.

    It's C#, the 'joke' is that with the e you get a warning 'Variable e is declared but never used', so they removed it.

    And there's TRWTF - assuming developers using a language will write shite.

    Um, ok. I think you almost the comment...

  • tragomaskhalos (unregistered) in reply to callingFoul
    callingFoul:
    Rawr:
    callingFoul:
    What language is this? This wouldn't even compile in Java without the 'e'.

    It's C#, the 'joke' is that with the e you get a warning 'Variable e is declared but never used', so they removed it.

    And there's TRWTF - assuming developers using a language will write shite.

    Silently eating an exception is understandable (though not forgivable) in Java because the code won't compile without either the try ... catch or an exception specification (which then needs to be propagated to all callers). But C# does not have that problem so this is both both unforgivable and inexplicable !

  • Dawn (unregistered) in reply to StupidTheKid
    StupidTheKid:
    Oh, how I wish this story was fake... We were asked to do the same in our codebase; to remove all compilation warnings without changing behavior.

    There is seemingly a market for software that behaves like a pack of rabid werewolves.

    Well duh, yeah... whom else would the software that behaves like a one-hundred year old vampire wistfully trying to overcome his darker nature while dating high school girls that are 85 years his junior have to fight?

    Did I mention the vampire's handwriting IME is so beautiful and perfect? No? Oh, well, it so totally is.

  • Gary (unregistered)

    I use this pattern all the time in javascript. Maybe I'm looping through an array and want to do something (call methods, change properties) that only some of the elements have. I'm too lazy to inspect each one, so I'll just try and catch.

  • Lil Kim Jon Ill (unregistered) in reply to zunesis
    zunesis:
    C-Octothorpe:
    zunesis:
    Even better

    That actually is better (at least there is something being outputted as opposed to the silent scream of a caught exception), but you'll still get the compiler warning.

    I meant "better" as in "more ironic" but whatever.

    Ironic better is best better.

  • (cs) in reply to zunesis
    zunesis:
    C-Octothorpe:
    zunesis:
    Even better

    That actually is better (at least there is something being outputted as opposed to the silent scream of a caught exception), but you'll still get the compiler warning.

    I meant "better" as in "more ironic" but whatever.

    I realized that, but wasn't sure if you knew that your example (although technically wouldn't compile) was actually an improvement.

    Anyway, excuse me while I reboot my sarcasm detector...

  • zunesis (unregistered) in reply to C-Octothorpe
    C-Octothorpe:
    zunesis:
    C-Octothorpe:
    zunesis:
    Even better

    That actually is better (at least there is something being outputted as opposed to the silent scream of a caught exception), but you'll still get the compiler warning.

    I meant "better" as in "more ironic" but whatever.

    I realized that, but wasn't sure if you knew that your example (although technically wouldn't compile) was actually an improvement.

    Anyway, excuse me while I reboot my sarcasm detector...

    After all the times I've been ribbed on this site...

Leave a comment on “The Pesky "e"”

Log In or post as a guest

Replying to comment #352459:

« Return to Article