Skip to main content

gen_wasm_error_methods

Function gen_wasm_error_methods 

Source
pub fn gen_wasm_error_methods(
    error: &ErrorDef,
    core_import: &str,
    wasm_prefix: &str,
) -> String
Expand description

Generate a #[wasm_bindgen] opaque struct for an error type together with an impl block that exposes the whitelisted introspection methods (status_code, is_transient, error_type) declared in error.methods.

The struct follows the same pub(crate) inner: CoreType convention used by all other opaque WASM handles in the codebase.

wasm_prefix is the full WASM type prefix string (from config.wasm_type_prefix(), e.g. "Wasm"). The generated struct name is {wasm_prefix}{error.name} (e.g. WasmLiterLlmError).

Returns an empty string when error.methods is empty so callers can unconditionally append the result without adding noise to the output file.