dilshod / xlsx2csv

Convert xslx to csv, it is fast, and works for huge xlsx files
MIT License
1.66k stars 302 forks source link

Use `raise XslxValueError` and other error handling improvements #235

Closed cnpryer closed 2 years ago

cnpryer commented 2 years ago

fixes #233 by

cnpryer commented 2 years ago

what if we did a little more and also replaced eprint with raisees where eprint was called and where sys.stderr.write is called? https://github.com/dilshod/xlsx2csv/blob/ee4d40cf543903a44083a92c97a1912af719ff0e/xlsx2csv.py#L1118

edit: added to the PR (see above)

cnpryer commented 2 years ago

@ghuls! You're the best. Thanks for the pointers.

Now that I'm curious, is it more ideal to use sys.stderr.write + a sys.exit or should this just throw a sys.exit?

https://docs.python.org/3/library/sys.html#sys.exit

ghuls commented 2 years ago

@ghuls! You're the best. Thanks for the pointers.

Now that I'm curious, is it more ideal to use sys.stderr.write + a sys.exit or should this just throw a sys.exit?

https://docs.python.org/3/library/sys.html#sys.exit

Seems like sys.exit is viable for writing the error message.

cnpryer commented 2 years ago

What about this guy under the main https://github.com/dilshod/xlsx2csv/blob/ee4d40cf543903a44083a92c97a1912af719ff0e/xlsx2csv.py#L1205

ghuls commented 2 years ago

It should be hanlded by: https://github.com/dilshod/xlsx2csv/blob/ee4d40cf543903a44083a92c97a1912af719ff0e/xlsx2csv.py#L1205 , but could also be handled explicitly.

This should also raise a InvalidXlsxFileException exception: https://github.com/dilshod/xlsx2csv/blob/ee4d40cf543903a44083a92c97a1912af719ff0e/xlsx2csv.py#L1039

dilshod commented 2 years ago

It seems good