Language Guide
Error Handling
try/catch/finally and throw in GSET, with exact per-target output.
Implemented
try / catch / finally
try {
result = 10 / 2
print(result)
} catch e {
print("error", e)
} finally {
print("done")
}| Target | Output |
|---|---|
| Python | try: / except Exception as e: / finally: |
| JavaScript | try { … } catch (e) { … } finally { |
| Ruby | begin / rescue => e / ensure / end |
The JavaScript catch is brace-correct (regression-tested for duplicate }). Specifying an exception type uses it:
catch ValueError e {
print(e)
}Python receives except ValueError as e:.
throw / raise
if score < 0 {
throw "invalid score"
}| Target | Output |
|---|---|
| Python / Ruby | raise "invalid score" |
| JavaScript / Java | throw "invalid score"; |
Target caveats
- Python, JavaScript, Ruby: fully functional — catch, finally ordering, and exception propagation all follow the target's native semantics.
- Java: the try/catch/finally block is emitted in Java syntax. Since GSET functions become static methods inside
Main, keep exceptions within method bodies for now. - Go: Go has no
try/catch— the emitter currently prints C-styletry { … }which does not compile undergo run. Prefer error-return style or keeptryonly for non-Go targets. Named-exception handling in Go is Planned.