• (disco)

    I thought this one had simply taken the "don't catch generic exceptions" meme to its illogical extreme... until I scrolled down to the bottom and found he catches Exception anyway, just for good measure....

  • (disco) in reply to Julia

    You never know when a EndOfWorldException will be thrown.

  • (disco) in reply to Eldelshell
    Eldelshell:
    You never know when a EndOfWorldException will be thrown.

    although if one ever is don't expect me to be debugging it. i'll be too busy running for that hidden bunker in the mountains.

  • (disco) in reply to accalia

    If I learnt something from Fallout is that I don't want to live in a bunker. I'll be the first one below that meteorite.

  • (disco) in reply to Julia

    I am sure that this is probably placeholder exception handling code that never got properly implemented.

  • (disco)
    remy:
    A good developer catches all of the possible exceptions. By that standard, the contractor who gave Martina this code must be one of the best

    Looks like he missed a few ones, tough.


    Filed under: You never know when your code starts throwing FederatedAuthenticationSessionEndingException
  • (disco) in reply to accalia

    Just keep an eye on this page or this page (maybe others, but those should be sufficient).

  • (disco) in reply to boomzilla

    ok, but that just warns me of one potential source of that exception!

  • (disco) in reply to accalia

    I suspect they're vulnerable to side effects of others, however, so you're probably covered.

  • (disco)

    When i see code like this (and i saw a lot of code like this) i start to like the Apple idea to not include exceptions in Swift.

  • (disco) in reply to maurizio
    maurizio:
    not include exceptions in Swift

    :wtf: Does it use C style error codes instead? Or does the ghost of Steve Jobs tell you that you're holding it wrong and there's no way an Apple programming language could be in an exception state?

  • (disco) in reply to Jaloopa

    Leaving out exceptions is the trendy new "hipsters throwing away everything we've learned over 20 years" thing. Swift and Go are programming languages perfectly suited to run that fixie bike.

    The rationale is:

    1. Exceptions in C++ suck, therefore there must be NO POSSIBLE LANGUAGE in which they do not suck (language hipsters also have never used C#, if they had they'd probably stop designing new bullshit languages and just use it.)
    2. 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.)
  • (disco) in reply to blakeyrat
    blakeyrat:
    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.)

    So is any flow handling. Are they going to take out if/else, for and while as well? Fuck it, lets all just write in assembly. That's "pure", right?

  • (disco) in reply to Jaloopa

    OMG THERE'S SUPER-SECRET DOUBLE-HIDDEN GOTOS ALL OVER!!!!! Gotos are like Hitler, but 50 times worse.

  • (disco) in reply to blakeyrat

    this makes me want to write an esoteric language where the line terminator is GOTO [next line number]

  • (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.)

    No, it's a super-secret double-hidden longjmp instead (early C++ runtimes implemented EH using setjmp and longjmp, even). Local branching is annoying when spaghettified, but works OK when hammered into neat control structures (the ifs, fors, and whiles we all know and love). Non-local branches, though, can make your head fa-spin if you aren't careful...and sometimes even if you are.

    TL;DR: Error handling will always be a pain in the rump, no matter what you do. You think you've handled everything? Along comes Murphy with a better error...just wait until closing a file decides to stop working on you!

  • (disco) in reply to Jaloopa
    Jaloopa:
    this makes me want to write an esoteric language where the line terminator is GOTO [next line number]

    FWIW, that's pretty much how Turing machines work.

  • (disco) in reply to Jaloopa

    The experimental RTX32 processor was sort-of-this-way this way at the assembler level -- each instruction carried an optional branch address with it.

  • (disco) in reply to Spectre
    Spectre:
    how Turing machines work
    tarunik:
    RTX32 processor was sort-of-this-way
    I guess I'll have to have another idea then. I can't be a hipster developer if it was cool before I was doing it
  • (disco) in reply to Jaloopa

    COMEFROM [line number] before every line?

  • (disco) in reply to Eldelshell

    "An error occured during comment process."

    Ok, ok, but someone had to say it!

    Eldelshell:
    You never know when a EndOfWorldException will be thrown.

    That was thrown some decades ago. However, since there was no catch process, we're currently caught in an infinite insanity loop. Don't believe me? Then why does thedailywtf.com exist? ;-)

  • (disco) in reply to aliceif

    That's called event subscribing.

  • (disco)

    Aha, I get it. TRWTF is the fact that programmers can't spell "occurred".

    Every single company I have worked at I've had to change the generic error message to correct the spelling of this bloody word. Look, guys, if a word's too complicated for your fluffy little head, then don't use it, use a nice easy kindergarten one instead. Otherwise people won't just think you're stupid, they will know it.

  • (disco) in reply to Matt_Westwood

    Look, guys, if a word's too complicated for your fluffy little head, then don't use it, use a nice easy kindergarten one instead. Otherwise people won't just think you're stupid, they will know it.

    ErrorHasHappened isn't much easier to spell.

    Anyway, I call this Porky Pig Spelling.

  • (disco)

    My local pet peeve is that almost everyone here mispronounces determine (emphasis on the first e, pronounced as the e in 'me'; mine as the word).

  • (disco) in reply to Jaloopa
    Jaloopa:
    Does it use C style error codes instead?

    No, it uses multiple return values:

    file, err := open(filename)
    if err != nil {
        //handle error
    }
    

    where err is an instance of the error interface, having one Error() : String method. I think the rationale in Go is that exceptions are undesirable in embedded software because they provide complications. Especially for real-time systems.

    I think in Swift you're supposed to use the Optional type (Maybe in Haskell, Option in Scala) or Either, which are far more common in functional programming languages than exceptions.

  • (disco) in reply to Matt_Westwood

    TR²WTF: Using "cancelled" with duplicated "l" - which is non-AmE - while forgetting to duplicate the "r" in "occurred" - which is seems more like an AmE thing to do.

  • (disco) in reply to blakeyrat
    blakeyrat:
    Exceptions in C++ suck, therefore there must be NO POSSIBLE LANGUAGE in which they do not suck (language hipsters also have never used C#, if they had they'd probably stop designing new bullshit languages and just use it.)

    While C# fans and Java fans would each argue that their way of doing exceptions is better than the others', they would also agree that both are superior to how C++ does it (which is full of fail and :wtf:) and how Go and Swift do it (where :headdesk: is the right emoticon). The whole point of an exception is that the code between the point which generates the error and the point where the error is handled can basically not give a :hankey: about the error, cleaning many things up immensely.

  • (disco)
    catch (FristPostNotFristException)
    {
      OnErrorOccurred(new ErrorOccurredEventArgs("An error occured during comment posting process.", ex));
    }
    
  • (disco)

    This is precisely the kind of crap code you get when someone blindly follows a "best practice" without thinking about why that "best practice" exists.

  • (disco) in reply to Craig_Wagner
    Craig_Wagner:
    why that "best practice" exists.

    For book sales, I believe.

  • (disco) in reply to tarunik

    I mark it as a unit test that failing to close the file fails to accept the exception except when closing the file fails as an exception.

  • (disco) in reply to dtech
    dtech:
    I think in Swift you're supposed to use the Optional type (Maybe in Haskell, Option in Scala) or Either, which are far more common in functional programming languages than exceptions.

    Yeah -- this is a much saner way to handle many types of errors, because they're errors you handle at the point where they happen.

    dkf:
    The whole point of an exception is that the code between the point which generates the error and the point where the error is handled can basically not give a :hankey: about the error, cleaning many things up immensely.
    For some types of errors (out of memory, for instance), this is indeed true. For many other types of errors (oftentimes the myriad 'user was a doofus' errors we have to deal with), you want to handle them at the point your code first encounters them, and exceptions just aren't all that well-suited for the job, unless you are unwinding a recursive-descent parse...
  • (disco)

    I f*&^ing love exceptions. They allow me to concentrate on business logic instead of language syntax. I also program mostly in Java. Everyone has their opinion, this is mine.

  • (disco) in reply to blakeyrat
    blakeyrat:
    (language hipsters also have never used C#, if they had they'd probably stop designing new bullshit languages and just use it.)

    It's funny that you think that would happen. They'd see their weird-ass language's defects as a badge of, well, whatever.

  • (disco) in reply to blakeyrat
    blakeyrat:
    See, "gotos are evil", right?

    People who don't understand the context of that statement are TRWTF.

  • (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.)

    So I've actually seen that happen... Something along the lines of

    try{
    bar=doFoo()
    if(bar==1)
    throw new GoToOtherOption()
    //other stuff here
    }
    catch(GoToOtherOption() e)
    {
    //do other things
    }
    

    On the other hand, that is DEFINITELY doing it wrong so your argument is perfectly correct...

  • (disco) in reply to blakeyrat
    blakeyrat:
    (language hipsters also have never used C#, if they had they'd probably stop designing new bullshit languages and just use it.)

    Yes, because C# obviously is the best programming language that will ever be made and all newer programming languages are bullshit and unnecessary. As was the case with Java, Delphi, C++, Ada, C, Pascal, Basic, ALGOL and FORTRAN.

    I think that C# is probably about the best you can do for a C++/Java/C# style imperative OOP-language. But that is not the only paradigm we have. It would be a sad world if we stopped developing better ways to instruct computers a meager 60 years after we've started.

  • (disco) in reply to dtech
    dtech:
    I think that C# is probably about the best you can do for a C++/Java/C# style imperative OOP-language. But that is not the only paradigm we have. It would be a sad world if we stopped developing better ways to instruct computers a meager 60 years after we've started.
    QFT because a Like is not enough -- Blakey clearly has a Blub problem whenever he looks at Lispy things, Haskell, or ML dialects...(and with the advent of cross-language platforms like the JVM and CLR, there's no reason to be hog-tied to a language for its library ecosystem any longer).
  • (disco) in reply to blakeyrat

    Exceptions are not like GOTO as much as like COME FROM.

    If you want INTERCAL, you know how to search for it.

  • (disco)

    Speaking of WTFs, did anyone notice that the finally clause handles a cancelled backup even if no exception occurs?

  • (disco)

    What is it with Remy always hotlinking Wikipedia images? DailyWTF can't afford their own image hosting?

  • (disco) in reply to blakeyrat

    Naw, the answer is that it's not its own structure; it's technically part of your return type, hence the use of Either-like constructs to abstract the returning of a value that may be one of two types, kind of like an informed type union. Very functional in style.

  • (disco) in reply to dtech
    dtech:
    I think that C# is probably about the best you can do for a C++/Java/C# style imperative OOP-language. But that is not the only paradigm we have. It would be a sad world if we stopped developing better ways to instruct computers a meager 60 years after we've started.

    I agree, but it would be MORE of a sad world if we developed new languages by ignoring all our current experience.

    C# does a pretty good job of introducing new language ideas as soon as they've been proven to be non-crackpot.

  • (disco) in reply to tarunik
    tarunik:
    a Blub problem

    Cool, first time I'd heard that term... I feel it for Haskell.

    http://en.wikipedia.org/wiki/Paul_Graham_(computer_programmer)#Blub

  • (disco) in reply to blakeyrat
    blakeyrat:
    I agree, but it would be MORE of a sad world if we developed new languages by ignoring all our current experience.

    You mean like that guy we ran off who was working on yet another Lisp dialect?

  • (disco)

    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")
    
  • (disco) in reply to antiquarian
    antiquarian:
    **we** ran off

    Third person royal we?

  • (disco) in reply to boomzilla

    Guilty as charged.

  • (disco) in reply to Zylon
    Zylon:
    What is it with Remy always hotlinking Wikipedia images? DailyWTF can't afford their own image hosting?

    WIkipedia probably deserves it.

    I CBA to check, but maybe they don't care. Some sites don't--xkcd even gives you a URL for hotlinking on all the comics.

Leave a comment on “Structured Exceptions”

Log In or post as a guest

Replying to comment #:

« Return to Article