Add shared DMException for DM runtime errors - #2695
Conversation
|
The goal of this PR is not necessarily to be merged as-is, but to demonstrate and discuss a possible workflow for handling DM-originated exceptions. The proposed workflow has three stages: Create a shared DMException type so DM-originated errors have a distinct type from internal C# exceptions. This PR currently focuses on demonstrating the first two stages. I would like feedback on whether this is the intended direction, particularly on how DMException should be handled at the top level and what information should be shown in normal versus debug mode. If this direction makes sense, the remaining conversion can be split into smaller, focused PRs rather than attempting to change the entire exception hierarchy in one large change. |
|
The introduction of Any uncaught exception within executed DM code is handled by DreamThread's HandleException method. Here you can check if the exception is of type |
thanks for the quick response, I will start working u can expect the change soon. |
|
Hey! I’ve pushed the dmexception-shared branch with the changes to use DMException for the DM-facing runtime errors. I also verified that the project builds successfully and all tests pass. If there’s anything I missed or anything that needs to be adjusted, I’m happy to do any follow-ups. |
|
all the changes are strightforward dm exceptions I might have missed some but I didn't incorrectly include any |
Co-authored-by: wixoa <wixoag@gmail.com>
|
all 4 changes requested are done. thanks for the quick review @wixoaGit |
Co-authored-by: wixoa <wixoag@gmail.com>
|
The failing test is unrelated, I think #2677 made it flaky. |
Context
While investigating the use of generic
Exceptionin the DM runtime, I found that this is substantially larger than a single-file change.throw new Exception(...)is used across OpenDream for several different categories of failures: DM-facing runtime errors, runtime/VM invariants, resource handling, compiler/bytecode validation, and other internal errors. Determining which cases should becomeDMExceptiontherefore requires distinguishing DM-originated failures from OpenDream implementation failures.I initially focused on
DMOpcodeHandlers, where several cases were straightforward DM errors. I also verified this behavior with faulty DM programs: for example, invalid arithmetic operations and division by zero now produceOpenDreamShared.DMExceptionwhile preserving the existing DM error message and behavior.Current change
This PR introduces the shared
DMExceptiontype and applies it to the confirmed DM-facing cases inDMOpcodeHandlers.The intention here is not to change how these errors behave, but to give DM-originated runtime failures a distinct exception type.
Question about the intended design
Before expanding this conversion further, I'd like to confirm the intended architecture.
Once
DMExceptionexists, should it:Exceptionat DM-facing failure sites while being handled by the existing runtime exception path?DMExceptionand converting it into a DM-visible runtime error?The distinction matters because there are many additional
throw new Exception(...)sites, and some are clearly DM-facing while others appear to represent OpenDream/VM invariants. Converting everything mechanically could incorrectly classify internal failures as DM errors.I'd therefore appreciate guidance on the intended handling and boundary for
DMExceptionbefore continuing with the remaining cases.If the intended approach is confirmed, I think the remaining conversion would be better split into smaller, independently reviewable changes rather than making one very large cross-cutting PR.