Suppose I am writing a program in F# for end-users. If there is an unhandled exception, the program will crash.
Now suppose that I want application-specific data in the crash report. I can get this by catching all exceptions, logging the relevant data, and then rethrowing the exception. Is this good or bad practice?
Definitely a good practice.
This will help you debug problems that arise in the field. Over time this leads to an ever more reliable program (assuming your team isn’t adding bugs faster than fixing them).
Think about what application data to include in the log to answer questions you’ll have about what caused the error.
Also be careful not to include user private information or personally identifying information (PII) if you can help it. If you can’t help it, give the user full disclosure before they send you the log.
There is a class of bugs that are very difficult to debug without a log. Those are bugs that we have no hypothesis about what made it happen or no confidence that a potential fix will fix all cases. Again, the error log is your friend and think about what pieces of data you’ll want to know about if it does arise.