this post was submitted on 17 Jun 2023
41 points (93.6% liked)

Programmer Humor

32410 readers
1 users here now

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

Rules:

founded 6 years ago
MODERATORS
 

Brilliant exception handling I found in an app i had to work on

you are viewing a single comment's thread
view the rest of the comments
[–] chillhelm@lemmy.world 2 points 2 years ago

Depending on the language it either does nothing and just adds code bloat or (and this would be much worse) it will catch any exception that can be implicitly cast to type Exception and throw it as type Exception. So the next higher scope would not be able to catch e.g. a RuntimeException or w.e. to handle appropriately. It could only catch a regular Exception even if the original error was a more detailed type.