How do I handle errors in Ren'py - python

I'm making a game using Ren'py (based on python) and most errors aren't shown, especially the errors in python code. Is there a possibility to check for possible errors at compile time and how do I get where some errors occur? If there are errors the game normally doesn't run or breaks at the a errors appearance without a message.Is there maybe a file, where they are written in or something like that? Or do I have to debug using logs everywhere?

Compile errors will be shown when you first try to compile the RPY files. They will be put in "errors.txt" in your project directory. Most errors are not found at compile-time, however, and will only show up once you encounter them at run-time.
You can use Lint to check for some common errors (It's called "Check Script (Lint)"), but mostly you'll have to playtest to ensure there are no errors. Errors during playback should pop up a gray screen showing the error and traceback with the option to Ignore, Rollback, or Quit. Is this screen not showing up for you?

If you're looking for some kind of intellisense like you have for some languages, where as you write the code the IDE shows errors, then it doesn't exist. You have to launch the game so that the code is compiled, just then Ren'py will show you errors. You can see them in the editor or in the errors.txt that Ren'Py creates. To test you python code you can launch the game and type Shift + O to open the console.

Related

Python Debugging: Given an error, can I step backwards, fix the error, and continue the program?

My current (PyCharm based) debugging workflow is to run a program in debug mode. When I run into an error, I fix it, and restart the program from the beginning.
Is it possible to save re-running the healthy part of the program by moving the program back by one step, fix the issue, and continue the program?
Is there a general way to do this, and one specific for PyCharm?
[edit:]
this is related but not similar to Is there "Edit and Continue" in PyCharm? Reload code into running program like in Eclipse / PyDev? , as there the author anticipates halts the program before an error occurs. here, i consider an error state

Python quit upon hitting the debug point, throw "called Tcl_FindHashEntry on deleted table" Error

I am running my Python script using Pycharm on Mac.
The script is reading, processing and plotting some data.
When I place a debug point(often shortly after I plotted some charts), I encountered "python quit unexpectedly". My debugger logged:
"called Tcl_FindHashEntry on deleted table"
Would you please help? I want the program to stop at the debug point, instead of quitting.
Your error looks like its coming from the backend of MatPlotLib. Here is an open bug which references the same error. The bug may or may not be what you are experiencing, but has to do with window sizing and multiple screens.
As troubleshooting:
If multiple monitors or a dock are in use, try removing them from the equation.
Use Windows to examine breakpoint. (Bug appears Mac-specific.)

Unable to run python code on Visual Studio, crashes after Launching Debug Editor

I was trying to get datetime.py working as one of the functions from it just didn't exist in my datetime.py file. In my datetime.py the fromiso() function is not present in the code. To test it I opened a new VS project and tried compiling a small code snippet that would only invoke the missing function from datetime after import, and that's when I first encountered this problem. I'm not sure if this is related to this problem, but this is the last thing I was doing.
When running the code it will flash console quickly before opening "Launching debug adapter" window, this will prevent me from doing anything for maybe 10s and then will return to the starting point having neither executed my code nor opened the debugger.
Now I am unable to run any program whatsoever, running with either ctr+f5 or fn+f5 leads to same glitch. I have not touched anything in the VS settings prior. I have tried powercycling just for a good measure, but sadly that didn't fix anything. Running as admin yields same result.

have ipython open editor at an error in a script

When running a script in Ipython (with %run) and there is an error in the script, is it possible to open an editor at the line of the error or have an open editor jump to that line?
Automatically this is not happening, although one could implement something like that. The question is, what would be the correct file to open? The backtrace will reveal all possible files in which the functions raised the error. In a large project, it would not be clear in which file the error is, is it with the caller or callee who made the error?
Most advanced IDEs e.g. eclipse with pydev allow direct jumps to the lines and function calls, so it is covered there.
on an ipython level you could do
%edit file_named_in_error.py

Save cx_freeze errors

So when a python program has been frozen using cx_freeze it opens up an alert whenever the program crashes the only problem is the only way to distribute the traceback (for bug reports) is by screenshot-ting the alert box which is a bit of a pain (you can't copy text from the alert box).
Is there any way to save cx_freeze error reports? For example by writing them into a crash-log file. It seams a shame to present the crashes in such a helpful way and yet have no way of easily sending crash reports to developers (screenshot-ting being a but tedious).
I think it is actually possible to copy the text from a Windows message box, but I agree that it's not obvious to users that you can do that.
It should be possible to set sys.excepthook to a function that saves the error and traceback somewhere. This will stop cx_Freeze displaying the error message box, so it's up to you to notify the user about errors if that's appropriate.

Categories