• (disco) in reply to Nigel
    Nigel:
    Of course, the constructor called by

    new ErrorOccurredEventArgs("An error occured during backup process.", ex)

    should itself throw the exception

    new MisspelledEnglishException("occured should be spelled as occurred")

    If we're going to nitpick the message should be "there was an error during the backup".

  • (disco) in reply to blakeyrat
    blakeyrat:
    See, "gotos are evil", right? And if you have a try/catch, that's exactly like a super-secret double-hidden goto!!! (Seriously, I've heard this argument multiple times. What. The. Fuck.)

    Well, you have to understand that "gotos are evil" because they can be used to violate the principles of structured programming. In that sense, it's kind of like banning baseball bats because bats can be used in dark alleys for evil things.

    But...it is true that exceptions violate the principles of structured programming, as they were defined way back when. I've even raised that objection myself. But mostly, that depends again on how you use them, just like it depends on how you use goto. (Yes, Virginia, goto can be used to write structured programs.)

    Nowadays, I boil it down to two issues: How the implementation works (good vs. evil) and how you (ab)use the features. Use the feature badly, and you will have a hole in your foot from where you shot yourself. Have an evil implementation, well, you can shoot yourself in the foot even if you try to do it right.

    C++ implementation, at least the first iteration: Evil. Almost impossible to use it without shooting yourself in the foot. It might be better now, I know they've done changes, but I haven't used C++ for a while...

    On the other hand, Java has a solid implementation. As noted above, some zealots might say, "All exceptions are evil," because, "structured programming." To them I say, "Get a good implementation," and "Who made structured programming a god?"

  • (disco) in reply to CoyneTheDup
    CoyneTheDup:
    Nowadays, I boil it down to two issues: How the implementation works (good vs. evil) and how you (ab)use the features. Use the feature badly, and you will have a hole in your foot from where you shot yourself. Have an evil implementation, well, you can shoot yourself in the foot even if you try to do it right.

    Makes sense so far...

    CoyneTheDup:
    C++ implementation, at least the first iteration: Evil. Almost impossible to use it without shooting yourself in the foot. It might be better now, I know they've done changes, but I haven't used C++ for a while...
    The C++ folks have this more-or-less figured out, and have in the process figured out how resource deallocation and exception handling *should* interact, instead of dumping it on the programmer with a `finally` block.
    CoyneTheDup:
    On the other hand, Java has a solid implementation. As noted above, some zealots might say, "All exceptions are evil," because, "structured programming." To them I say, "Get a good implementation," and "Who made structured programming a god?"
    What makes you look to Java? Checked exceptions were a massive waste of their time and breath, and their rather tenacious grip on the infernal abomination known as `finally` makes them look oafish in this day and age.
  • (disco) in reply to tarunik
    tarunik:
    What makes you look to Java? Checked exceptions were a massive waste of their time and breath, and their rather tenacious grip on the infernal abomination known as finally makes them look oafish in this day and age.

    Well, I'm familiar with it. So? Does finally make it an evil implementation? No.

    When I talk about the difference between "good" and "evil" here, I'm talking about the implementation in the language. A good language implementation is moderately safe to use, requiring a moderate level of stupidity and misuse to shoot self in foot. On the other hand, evil implementations, such as the original C++ exception structure, arrive with machine gun already firing at a high rate, and keeping yourself from being shot in the foot requires fancy footwork (too bad if your footwork isn't great).

    By that standard, Java is a good implementation, even if it is sometimes annoying to use.

  • (disco) in reply to CoyneTheDup
    CoyneTheDup:
    Well, you have to understand that "gotos are evil" because they can be used to violate the principles of structured programming.

    The entire time I've used C#, I've used GOTO exactly once. Situations where it's useful or makes things more readable are incredibly rare IMHO (but do come up).

  • (disco) in reply to CoyneTheDup
    CoyneTheDup:
    On the other hand, evil implementations, such as the original C++ exception structure, arrive with machine gun already firing at a high rate, and keeping yourself from being shot in the foot requires fancy footwork (too bad if your footwork isn't great).

    I think that you're thinking of the mid-90s then...because I haven't seen any bullets flying out of C++ EH in the code I work on! (And this is using the MFC catch-by-pointer business, too.)

  • (disco) in reply to Masaaki_Hosoi

    No argument there. But structure is possible with goto. I still have to write COBOL and, while my company permits it, it is restricted to the equivalent of a C "return" statement. (Which also violates the old rules of structured programming by the way.)

    Even then, I avoid it as much as possible.

  • (disco) in reply to tarunik

    As a matter of fact, the last time I used C++ was ... the mid 90's.

    I'm not up to date on the current implementation, but discussions I have seen indicate it is vastly improved.

  • (disco) in reply to Matt_Westwood

    Everyone knows the only propper error message is: > Something went wrong.

  • (disco) in reply to CoyneTheDup
    CoyneTheDup:
    I'm not up to date on the current implementation, but discussions I have seen indicate it is vastly improved.

    ... standardized, yes. Significantly expanded, yes. Improved? Hmmmm.

  • (disco) in reply to geoff
    geoff:
    Everyone knows the only propper error message is:> Something went wrong.

    Microsloth Outlack once gave me this error message: The action failed to complete. The action failed to complete.

    That seems to me to be a pretty proper error message, too. Just think:

    1. It's equal to "something went wrong" in the antecedent category: You have no idea what "something" or the "action" was...you're left to guess.
    2. But it's better first of all, because it assumes that the action could ever complete--and we all know that's a stretch with Microsloth.
    3. The message was repeated. Now at first that might strike you as a detraction, but it really isn't. Just think: You have twice the information about nothing (twice zero is still zero)!

    So I vote that "The action failed to complete. The action failed to complete." is a better message than "something went wrong;" I vote for Outlack!

    Outlack! Outlack! Outlack! Outlack! Outlack! Outlack!

  • (disco) in reply to CoyneTheDup
    CoyneTheDup:
    Outlack! Outlack! Outlack! Outlack! Outlack! Outlack!

    You seem angry about Outlook. Perhaps Lotus Notes would be more your thing.

  • (disco) in reply to FrostCat
    FrostCat:
    You seem angry about Outlook.

    Why would you think I focus on Outlack? I pick on everything Microsloth makes, equally. Outlack is a favorite yes, but there's also their patented Guess Wrong technology, which they offer in the form of their MAG/NET (Most Aggravating Guess/Not Ever Timesaving) user interfaces.

    Drives me crazy every day. Surely Notes could not be worse, right?

  • (disco) in reply to CoyneTheDup
    CoyneTheDup:
    Why would you think I focus on Outlack?

    Because you talked about Outlook and not other stuff?

  • (disco)

    I can only assume the many many people who routinely code this way merely have a deep-seated hate for sysadmins and regular users. At least with commercial code people can threaten to take their ball and go home if it looks too shitty; open source developers often actively resist and sometimes ban anyone who asks for simple things, like a decent error message.

    And then they get all pissed and close reports from anyone posting that half-assed error.

  • (disco)

    Possible partial defense of the article: perhaps ErrorOccurredEventArgs has an overloaded constructor, one for each of the Exceptions types caught.

  • (disco) in reply to Menno_van_den_Heuvel

    isn't that just pushing the WTF deeper?

  • (disco) in reply to Jaloopa

    No, you're doing what any senior enterprisy architect would do: abstract the WTF.

  • (disco) in reply to CoyneTheDup
    CoyneTheDup:
    Surely Notes could not be worse, right?
    I see you have no experience with Notes then ...
  • (disco) in reply to CoyneTheDup
    CoyneTheDup:
    Surely Notes could not be worse, right?

    At least Outlack doesn't crash in DoDragDrop...

  • (disco) in reply to CoyneTheDup
    CoyneTheDup:
    Why would you think I focus on Outlack? I pick on everything Microsloth makes, equally. Outlack is a favorite yes, but there's also their patented Guess Wrong technology, which they offer in the form of their MAG/NET (Most Aggravating Guess/Not Ever Timesaving) user interfaces.

    Drives me crazy every day. Surely Notes could not be worse, right?

    This guy has to be a joke account.

  • (disco) in reply to CoyneTheDup
    CoyneTheDup:
    On the other hand, evil implementations, such as the original C++ exception structure, arrive with machine gun already firing at a high rate

    Metaphors are a barrier to coding discussion. Examples allow people to let you know if it's been improved or not; I for one have no fucking idea what you're complaining about :/

  • (disco) in reply to CoyneTheDup
    CoyneTheDup:
    I pick on everything Microsloth makes, equally.

    Slashdot is that way, thank you.

  • (disco) in reply to CoyneTheDup
    CoyneTheDup:
    I pick on everything Microsloth makes, equally

    Don't. Some things are far more deserving of it than others.

  • (disco) in reply to foxyshadis
    foxyshadis:
    open source developers often actively resist and sometimes ban anyone who asks for simple things, like a decent error messageLikes column.

    But we wore 'em down.

  • (disco) in reply to redwizard

    I think this exception has been caught.

    Something like,

    currentUniverse = new Universe(currentUniverse.complexity * 2, currentUniverse.insanity * 2);

    and we're left in the universe the garbage collector is disposing of.

  • (disco)

    Let's hope the backup process doesn't overwrite the only existing backup, and the cleanup doesn't wipe out all files of that backup.

  • (disco) in reply to PWolff
    PWolff:
    and we're left in the universe the garbage collector is disposing of.

    That's true on several levels...

    PWolff:
    Let's hope the backup process doesn't overwrite the only existing backup, and the cleanup doesn't wipe out all files of that backup.

    What fun would that be?

  • (disco) in reply to redwizard

    [quote=redwizard] What fun would that be? [/quote] Uttered hopes are sent to the Murphy module by default, and that comes up with bizarre ideas no human could ever dream of.

Leave a comment on “Structured Exceptions”

Log In or post as a guest

Replying to comment #:

« Return to Article