171
you are viewing a single comment's thread
view the rest of the comments
[-] TimeSquirrel@kbin.melroy.org 9 points 3 days ago

I'm just a hobbyist but...are you guys using exceptions like they're conditional statements?? I thought those were for only when shit is seriously wrong and execution can't continue in the current state. Like if some resource was in a bad state or some input was malformed.

Or maybe I haven't worked on anything complex enough, I dunno.

[-] Odinkirk@lemmygrad.ml 2 points 3 days ago

You can set up a global exception handler in some frameworks. By having multiple (not a crazy amount) of exceptions, you can set up logic for how to handle that kind of error. Then you can just throw the exception instead of writing individual catch blocks.

This is especially helpful in things like a REST API where user input can cause all kinds of fun, let alone network issues, problems with your data source, etc.

load more comments (4 replies)
this post was submitted on 13 Nov 2024
171 points (98.3% liked)

Programmer Humor

32483 readers
300 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS