Files
hakorune/apps/tests/block_postfix_catch_basic.nyash

22 lines
365 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Blockpostfix catch sample (Stage3 gated)
// Enable: NYASH_PARSER_STAGE3=1 (or NYASH_BLOCK_CATCH=1) + NYASH_TRY_RESULT_MODE=1 for JSON v0 Bridge
function main() {
local y
y = 0
{
// try body
// do_something_dangerous()
throw "E"
} catch (e) {
// handle error
y = 42
} cleanup {
// cleanup
y = y + 1
}
return y
}