Essentially a nice wrapper around the TW debugger
This is the baseline error handling library which is built for goboscript. It is designed to be used with inflator.
No dependencies.
- Use the
try;
procedure to enter a try block. This will prevent any errors from immediately raising. - Catch any errors by error name using
if catch("error name")
- End the try/catch block using
validate_errors;
. This will raise any uncaught exceptions.
try;
say div(3, 0), 0.25;
if catch("ZeroDivisionError") {
log caught_exception.message;
} validate_errors;
Note
All code within the try block WILL be executed, even if errors ocurr, unless it is raised with force: true
!
This will immediately cause a breakpoint
and stop_all
, so there is no chance for any error catching. It is recommended to avoid this where possible.
...
Make sure you have inflator installed. It's installable from the gtp.
inflate install catch
add catch to your inflator.toml
config:
[dependencies]
# ...
catch = "catch"
use inflate install -e .
:
- clone the respository:
git clone https://github.com/inflated-goboscript/catch
cd catch
inflate install -e .
cd test
inflate
goboscript build
- open
test.sb3