this post was submitted on 17 Jun 2023
144 points (96.8% liked)
Programmer Humor
32222 readers
13 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
An exception will bubble up the stack until it enters a
catch
block that can handle it, and you may need additional logic to decide if you are finished, or it needs to go further up. (you may also intercept it just to add more data, or log it)throw;
allows you send the original exception further up, butthrow ex;
behaves the same as throwing a new Exception object, and therefore has a new trace. The throw statement doesn’t query any properties on the exception argument AFAIK, so it has no idea this exception has been previously thrown, but the IDE is smart enough to know you almost certainly don’t want to do this.