Skip to content

Exception Handling

Exception handling introduces try_table, throw, and related constructs for structured error handling.

(module
(tag $e (param i32))
(func (export "mayThrow") (param $x i32) (result i32)
(block $handler (result i32)
(try_table (catch $e $handler)
(if (i32.eqz (local.get $x))
(then (throw $e (i32.const 1))))
(i32.const 0)
)
)
)
)