Replies: 3 comments
-
I saw you mention implementing some kind of try-catch system in Wurst as well, so I'm going to throw my 2 cents in here. We already have facilities in StdLib for (very rudimentary) catching of errors. The I use this extensively in my own libraries, especially for FileIO stuff where a lot of things can go wrong (especially user-provided implementations for Persistable), and it works fine for catching errors, and carrying on in case of a failure. In fact, I rely on these errors being thrown to find out whether there was some kind of error in user code. If the thread doesn't crash, then I have no way of telling. This system can be extended to allow I think you could use this approach on the language level to implement a Then, the current built-in errors could be modified to throw I don't think it's a good idea to choose a "continue after error" approach, because it IMO leads to even more confusion. This was one of the biggest problems with trying to debug JASS code - if a native returned a On the other hand, I can totally get behind how this behaviour could be desired in other situations, where you just want to print an error or a warning and carry on anyway, for the sake of players. Some errors aren't that critical, after all. But it depends from case to case. I'd also like to comment on individual suggestions:
I'm not sure that's a good idea. If some class method returns an instance of another class, this could easily lead to a cascade of null-pointers, obscuring the original root cause. In complicated hierarchies, this is almost guaranteed to happen, and with or without "continue after error", the code will not work correctly.
I think this is possible. Double-free is not a critical error, most of the times, and is sometimes just programmer oversight trying to accidentally delete the same object twice in the same function. If it is a critical error, it will have likely lead to NPEs before the Double-free, so if the thread crashes on NPE but not on Double-free, that's fine, I think.
This could lead to all kinds of weird, obscure corruption bugs on leaks. Out of memory errors usually indicate a massive leak, and is something that almost certainly must be fixed. On the other hand, it heavily depends on the user code. If someone has reached the 30k-something limit on objects, it might very well be the case that the "older" objects are out of scope anyway.
I think this is fine, personally. A lot of JASS natives return default values on incorrect input anyway, so it wouldn't be too different from that. So long as the error is correctly logged, it should be fine. |
Beta Was this translation helpful? Give feedback.
-
for case 4
This does not cause too much runtime burden. |
Beta Was this translation helpful? Give feedback.
-
I'm not gonna repeat everything from other packages, but my main reason for this ticket is, that non-destructive errors, like double frees, cause the thread to crash, which often isn't desirable. |
Beta Was this translation helpful? Give feedback.
-
Problem: Currently we crash the thread if there is an error ingame.
This can spoil the game so people are sad.
One idea is to take a more "Javascript like approach" and try to continue executing code.
Concretely, we have the following runtime exceptions created by the compiler:
Instead of crashing the thread, we could just print the error message and then
m
in cases 1 and 2.This issue for discussing which of those make sense, or whether we should keep the current behavior.
Beta Was this translation helpful? Give feedback.
All reactions