-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide Visible Error if <py-env> paths is used in a local HTML file #311
Provide Visible Error if <py-env> paths is used in a local HTML file #311
Conversation
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JeffersGlass thanks, this is great! Left some comments that is worth checking/addressing but overall the PR intent lgtm. If you can address what's needed in the comments and check linting (that is causing CI to fail) I'd be happy to merge! 🚀
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JeffersGlass thanks for the contribution! Nice addition to gracefully fail in case of errors... I've made a couple of changes to merge main into the branch and to reuse the error handling elsewhere as well. TY!
Add a warning if a user tries to use Paths when opening an HTML file locally instead of using a webserver.
Specifically, if pyfetch() errors when trying to load a local file (given by paths), a warning will be logged to the console, explaining that a server is necessary to read from local files, and a warning (current a red <div> at the top of the <body> section) will be added to the screen. The console warning starts with 'PyScript' to draw users' (especially new users') attention there.
The method of showing the error is a new function showError() in utils.ts. The styling is very 1995 (see picture above) and should probably change as styling improves, but hopefully this provides a place to start.
Currently, the two errors from pyfetch (
Access to fetch at file:///...
andGET file:\\\...
are not suppressed, though it might be clearer if they were. My understanding is that since pyfetch is a thin wrapper around Fetch, hiding those errors in the console would mean monkey-patching pyfetch()? Or perhaps there's a cleverer way.Resolves #257, and hopefully clarifies other issues listed there.