Skip to content
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

Improve error message when sketch file is executed without ever being saved #441

Open
villares opened this issue Apr 8, 2024 · 1 comment

Comments

@villares
Copy link
Collaborator

villares commented Apr 8, 2024

Running a module mode sketch file without saving causes the setup()/settings() separation feature to fail. The error message only mentions other issues that cause this feature to fail. It would be great if we could find a way of improving this.

image

The things that I can think of are:

  • Improve the error message mentioning that another cause of the problem is the file might not yet have been saved
  • Detect the unsaved state of the file on the IDE and provide a different message. On Thonny print(__file__) throws a NameError if the file was never saved.

Note: On Thonny IDE, this is not an issue using the plugin that enables imported mode, because then, if the sketch was never saved, the IDE prompts the user to save the file when you hit the run button!

@hx2A
Copy link
Collaborator

hx2A commented Apr 10, 2024

@villares , thanks for spotting this issue and opportunity to improve py5.

It might be possible for py5 to pre-emptively detect that the setup() function's __file__ is <string> and save it to a temporary file. I'll consider this as a possibility when I work on fixing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants