I am developing a Python package for use in Jupyter Notebooks. It will also be accessed via python module scripts but the Jupyter Notebook is an interface I am targetting. However the handling of errors is very ugly within Jupyter notebooks as there is no simple way to set up a try-catch mechanism within each cell.
I am therefore thinking of replacing all of my exception-raising with a simple print statement for Jupyter notebooks but with standard exceptions for non-Jupyter environments such as Spyder. To do this I will need to set some global variable within the Python package, which is do-able. So the user simply gets a polite error rather than a listing with a Python error report showing the culprit line.
Does anyone have any suggestions for a better approach ?