[BUG - Develop] Global Scripts loading doesn't catch parse errors
See original GitHub issueDescribe the bug
When there’s an error with loading a global scripts module, e.g. it imports the Room
class but that class has a syntax error, the loading error isn’t caught and the traceback points to this line with a KeyError
To Reproduce
Steps to reproduce the behavior:
- Create a simple global script which imports a class such as
Room
from your game dir, and add it tosettings.py
- Introduce a syntax error to your
Room
class, such as an extra space in an indent. - Reload the server.
- See error
Expected behavior
It’d be more useful if there was an error thrown which indicated that the script had failed being loaded (and, ideally, why), as the current error invariably leads people to think there is a problem with the global scripts dict in settings.py
.
Develop-branch commit
f093c8bcb
Additional context
I feel like it should be catching that kind of an error in class_from_module
or it should at least be throwing an exception in load_data
but neither seem to be doing so. Instead, they just silently don’t load the script.
Issue Analytics
- State:
- Created a year ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
How to tell if a <script> tag failed to load - Stack Overflow
Well, yes if the file LOADS and there is an error in the file itself, but if the file is not served up,...
Read more >What causes a Script error and how to solve them · Raygun Blog
A Script error in Raygun is one of the most cryptic error messages you may encounter. In this post we'll discuss in detail...
Read more >Error handling, "try...catch" - The Modern JavaScript Tutorial
So, an error inside the try {...} block does not kill the script – we have a chance to handle it in catch...
Read more >Window: error event - Web APIs - MDN Web Docs - Mozilla
The error event is fired on a Window object when a resource failed to load or couldn't be used — for example if...
Read more >JS: Error Handling - Medium
The errors that occur on the reading phase are called “parse-time” errors and are unrecoverable (from inside that code). Thats because the engine...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The error is much clearer, which is a definite improvement, but I’d prefer if the game failed to start due to a broken global script rather than continuing to start without it. If I have a global script, the chances that I have other systems relying on it are very high, so having the game start without that script available could cause a cascade of broken systems.
@Henddher That’s the one!