Is panic safe ? ( not about 'unsafe { }' )

( I am not talking about 'unsafe { ... }' )

I use a tiny app (works witch clipboard) for home using and it panics very often. :slightly_smiling_face:
It is ok to me, just says: "clipboard is empty".
But, is not the multiply program crashing dangerous for OS(Windows) or PC ( hard)?
Does not it damage installed rust?
Maybe, I have to handle this situation to make the program 'normal' exit ?

Panics are harmless, and do not damage anything.

7 Likes

If you are familiar with other languages, a panic is just an exception and from memory it even uses the same machinery as C++'s exceptions.

Triggering a panic will force each function to return until the panic is caught, calling the destructors for any variables so we can clean up things like allocations and database connections.

In general, a crash in your program won't delete

If killing the program immediately is a valid way to deal with an empty clipboard, then panics are fine.

Normally, I'll try to handle the error gracefully because that lets me print more human-friendly error messages.

5 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.