- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
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....
Admin
You never know when a EndOfWorldException will be thrown.
Admin
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.
Admin
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.
Admin
I am sure that this is probably placeholder exception handling code that never got properly implemented.
Admin
Looks like he missed a few ones, tough.
Filed under: You never know when your code starts throwing FederatedAuthenticationSessionEndingException
Admin
Just keep an eye on this page or this page (maybe others, but those should be sufficient).
Admin
ok, but that just warns me of one potential source of that exception!
Admin
I suspect they're vulnerable to side effects of others, however, so you're probably covered.
Admin
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.
Admin
: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?
Admin
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:
Admin
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?
Admin
OMG THERE'S SUPER-SECRET DOUBLE-HIDDEN GOTOS ALL OVER!!!!! Gotos are like Hitler, but 50 times worse.
Admin
this makes me want to write an esoteric language where the line terminator is GOTO [next line number]
Admin
No, it's a super-secret double-hidden
longjmp
instead (early C++ runtimes implemented EH usingsetjmp
andlongjmp
, 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!
Admin
FWIW, that's pretty much how Turing machines work.
Admin
The experimental RTX32 processor was sort-of-this-way this way at the assembler level -- each instruction carried an optional branch address with it.
Admin
Admin
COMEFROM [line number] before every line?
Admin
"An error occured during comment process."
Ok, ok, but someone had to say it!
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? ;-)
Admin
That's called event subscribing.
Admin
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.
Admin
ErrorHasHappened isn't much easier to spell.
Anyway, I call this Porky Pig Spelling.
Admin
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).
Admin
No, it uses multiple return values:
where
err
is an instance of theerror
interface, having oneError() : 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) orEither
, which are far more common in functional programming languages than exceptions.Admin
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.
Admin
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.
Admin
Admin
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.
Admin
For book sales, I believe.
Admin
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.
Admin
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.
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...Admin
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.
Admin
It's funny that you think that would happen. They'd see their weird-ass language's defects as a badge of, well, whatever.
Admin
People who don't understand the context of that statement are TRWTF.
Admin
So I've actually seen that happen... Something along the lines of
On the other hand, that is DEFINITELY doing it wrong so your argument is perfectly correct...
Admin
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.
Admin
Admin
Exceptions are not like GOTO as much as like COME FROM.
If you want INTERCAL, you know how to search for it.
Admin
Speaking of WTFs, did anyone notice that the finally clause handles a cancelled backup even if no exception occurs?
Admin
What is it with Remy always hotlinking Wikipedia images? DailyWTF can't afford their own image hosting?
Admin
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.Admin
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.
Admin
Cool, first time I'd heard that term... I feel it for Haskell.
http://en.wikipedia.org/wiki/Paul_Graham_(computer_programmer)#Blub
Admin
You mean like that guy we ran off who was working on yet another Lisp dialect?
Admin
Of course, the constructor called by
should itself throw the exception
Admin
Third person royal we?
Admin
Guilty as charged.
Admin
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.