this post was submitted on 21 Feb 2025
904 points (95.7% liked)

Programmer Humor

20735 readers
408 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 1 day ago

You can do either, but you usually do neither. The best way is to throw a new exception for your situation and add the caught exception as an inner exception. Because rethrowing resets the stack trace, removing the context from an exception message that is often pretty vague, and "bouncing" with throw; doesn't tell the next exception handler that you already handled (part of) the exception.