Giter Club home page Giter Club logo

Comments (3)

giovannipizzi avatar giovannipizzi commented on June 18, 2024

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.

giovannipizzi avatar giovannipizzi commented on June 18, 2024

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.

agoscinski avatar agoscinski commented on June 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.