Comments (3)
Here is an example notebook where I add some wrapper code to display better information, both for SyntaxErrors when parsing the code, and then for any other exception (including NameError) when executing it:
code-widget-syntax-error-example-checkpoint.ipynb.zip
If you like the approach and the output, probably we need to think at how to put this code directly in the code widget (e.g., having the two wrapper codes directly wrapping the calls to get_function_object and wrapping the actual execution) to avoid that the user has to remember to wrap them every time?
@dou-du @agoscinski happy to hear feedback on the suggested approach, and possibly to the integration in the code widget
from widget-code-input.
I proposed a solution. However I worked on master, while I think I should have done it in develop? This includes the two commits I directly pushed to add black and other pre-commits... @dou-du let me know if you know how to fix it, or we should discuss
from widget-code-input.
I would say there is no need to catch the error in case of an SyntaxError
when getting the function object in wid.widget_function_object()
, since the error is displayed correctly in this case.
I was hoping there is an approach that forwards to the python error machinery such that we do not have this hacky way of imitating the python error message. But it seems to be a general problem of python for executed strings.
https://stackoverflow.com/questions/35564208/python-traceback-of-a-string-in-exec
So I am fine with this solution. I would just keep the same error type name add the proper coloring to the error message.
https://stackoverflow.com/a/287944
from widget-code-input.
Related Issues (9)
- pip install fail HOT 3
- Binder example too slow to open HOT 2
- multiple calls to IPython.display() renders CodeInput in wrong cell HOT 1
- Widget get wrong height and width in the JupyterLab 4.x HOT 2
- code_theme parameter in the __init__ of the widget should be documented HOT 2
- requirejs error with notebook==6.5.5
- string causes problem with the widget HOT 2
- Support for jupyterlab 2.x HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from widget-code-input.