generated from bitsquid_dt/dt-plugin-template
Error handling #5
Labels
No labels
bug
confirmed
bug
duplicate
bug
need-info
bug
new-report
kind
bug
kind
discussion
kind
documentation
kind
enhancement
kind
feature
kind
question
kind
upstream
stage
actionable
stage
blocked
stage
design
stage
proposal
status/good first issue
status/invalid
status/regression
status/wontfix
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
bitsquid_dt/p2p#5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Figure out a strategy for error handling.
The simple approach would be to only stick to what Lua can do, i.e. calling
lib_argerrororlib_errorright where the error happens. But that also removes all the nice stuff that error handling in Rust is capable of.dropvaluesResults to work with (from libraries, or in my own functions), it becomes a weird mixlua_cpcall) still wants alua_CFunction, not a Rust functionSo I think the better approach will be to build a wrapper function and a
thiserrorenum that allow me to do the normalResults everywhere, which are then translated right at the boundary.That wrapper could also catch
panic!()s (maybe limited to debug mode).And I think I will only need two implementations of that wrapper. One for the functions that get called by the engine (e.g.
setup_game) and one for the ones called by Lua. Those should be the only two signatures that need to be covered.There may also be errors that aren't directly related to a Lua function call, and we can't just call
lua.lib_error.For those, it might be necessary to store a list of errors that occurred, maybe with an extra
is_fatalflag, and then expose a module function where the Lua-side can occasionally fetch them, and display them.That would also allow to show errors in the usual UI popup. In the log, they are useful for debugging, but a display in the UI is certainly better to make the user aware.