Exceptions versus fail/error values? The religious debate continues...

Started by Darren Dirt, February 03, 2020, 12:14:39 PM

Previous topic - Next topic

Darren Dirt

Exceptions versus fail/error values?

The religious debate continues, a new YC thread started 2 hours ago and already has 147 comments/replies. "I'd like to have an aegument please..."

https://news.ycombinator.com/item?id=22225170

Cliffs(?) = Both sides are correct.
Depending on [17 different aspects of your particular case]. ;-)

Personally I like how (for example) document.querySelectorAll returns an array always, so if no matches then you can just check if 0==returnedArray.length -- but then what about document.querySelector? Should it return null, or undefined? Or throw an error? Hmmm...

( tbh this YT convo is a nice single place offering a balanced summary of the pros and cons as provided by a bunch of different people with varying developer experience, unlike that mostly-one-sided journey of exploration I travelled 5 months ago researching  checked vs unchecked exceptions in Java



_____________________

Strive for progress. Not perfection.
_____________________

Mr. Analog

As long as code isn't using exceptions as control flow logic because yikes

Sent from my Pixel 2 XL using Tapatalk

By Grabthar's Hammer

Darren Dirt

That's where the debate kicks in to high gear.

Many suggest a single "pop up to the main loop" handling of virtually every "exception" but then you start using a framework that uses exceptions to identify non-critical fail conditions and errors and then ... ugh.

I think what the Python community does is smart, from what little I heard, and what miniscule of that I recall. Actually it might not even be Python, idk.
_____________________

Strive for progress. Not perfection.
_____________________

Mr. Analog

Yeah there's a special place in hell for people who use exceptions for anything other than EXCEPTIONAL CONDITIONS likely the same mouth breathers who catch and eat an exception without logging or re-throwing - making debugging a royal pain.

//TODO: THIS EXCEPTION ALWAYS HAPPENS
THEN YOU'RE USING IT WRONG
By Grabthar's Hammer