catdad πŸ’– is a user on octodon.social. You can follow them or interact with them if you have an account anywhere in the fediverse. If you don't, you can sign up here.
catdad πŸ’– @tcql

programming confession:

i don't think i've ever written proper, *good* error handling ever πŸ˜•

Β· Web Β· 1 Β· 10

@tcql

I suspect most developers don't get past the equivalent of "ON ERROR DIE SCREAMING" in whatever language they use.

@starbreaker @tcql i'm not entirely sure how many developers get to the level of "i should do anything at all if this operation doesn't do what i want it to".

@tcql I think most people just focus on letting it crash securely, i.e., who cares about a null pointer, if you use my shit on the Ariane you are a fool

@tcql 90% of good error handling, as far as I can tell, is just making sure that errors always happen in the right place, and never happen in the wrong place. Tedious, I know.

@tcql It's programmers like you who made exception-throwing popular 😜 ;) ;) but seriously, being consistent about it is hard! I wrote a structured logging framework which helped me, because it let me log issues as return statements:
return $log->err('no config', $errno, $filename);
(Returns the tuple ("ERROR", "no config", $errno, $filename) after logging it)

@tcql Admittedly that doesn't address the need to check return values every single time, which is the harder part.

But even if the return value isn't checked, errors/warnings get logged, which is better than nothing!