center-randomize icon indicating copy to clipboard operation
center-randomize copied to clipboard

fix: error handling for file operations

Open trishan9 opened this issue 2 years ago • 7 comments

The code for the function read_tsv and read_prefs doesn't have explicit error handling for file operations. This modification will catch any File error operations, or IOError exceptions that occur when trying to open or read the file, and print an error message.

trishan9 avatar Apr 20 '24 09:04 trishan9

could you also also do the same for pref file as well ?

sumanashrestha avatar Apr 20 '24 09:04 sumanashrestha

could you also also do the same for pref file as well ?

sure!

trishan9 avatar Apr 20 '24 12:04 trishan9

please review, I have updated my PR accordingly! @sumanashrestha @horrormyth

trishan9 avatar Apr 20 '24 12:04 trishan9

👏👏

rajan-poudel avatar Apr 21 '24 14:04 rajan-poudel

The original code would exit when any of the error occurs and print stack trace.

26 added lines later, it still does essentially the same thing but with some extra error message which would have been fairly obvious with the exception name.

I am generally for proper error handling but just stating my observation.

sapradhan avatar Apr 22 '24 03:04 sapradhan

The original code would exit when any of the error occurs and print stack trace.

26 added lines later, it still does essentially the same thing but with some extra error message which would have been fairly obvious with the exception name.

I am generally for proper error handling but just stating my observation.

Disagreement: The client/user is not capable of dissecting the exception traceback, those are only for developers who can understand them. So, in any client use case, throwing exceptions to them is a bad idea. The user should be informed nicely about what went wrong regardless of how miserably the system failed. Here, the message is nicely written, and the user will know what went wrong.

horrormyth avatar Apr 22 '24 14:04 horrormyth

please resolve the conflicts, so that this can be merged

sumanashrestha avatar Apr 23 '24 02:04 sumanashrestha