this post was submitted on 07 Mar 2024
310 points (100.0% liked)

196

16246 readers
2873 users here now

Be sure to follow the rule before you head out.

Rule: You must post before you leave.

^other^ ^rules^

founded 1 year ago
MODERATORS
 
top 7 comments
sorted by: hot top controversial new old
[–] [email protected] 31 points 6 months ago

I wrote a small command line program that would crash if a keyboard interrupt was used to close it. I fixed the crash by catching the keyboard interrupt exception...but I couldn't do anything with it. The keyboard interrupt closes the program. Catching the interrupt only stopped the crash message from appearing. So my code basically looked like this.

[–] [email protected] 25 points 6 months ago (1 children)

Throw(e)

Make your problem someone else's problem.

[–] [email protected] 2 points 6 months ago

Wrap it in a RuntimeException and the compiler will be happy to.

[–] [email protected] 17 points 6 months ago
[–] [email protected] 9 points 6 months ago

That formatting, on the other hand, is not going away

[–] [email protected] 6 points 6 months ago

very true 😤👍

[–] [email protected] 3 points 6 months ago

Much like teeth … and friends