Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Identity of exception objects across frames #22

Open
@eholk

Description

@eholk

Should exceptions remain strictly equal across call frames?

let wasm_module = /* instantiate a module with appropriate functions */

var saved_exception = undefined

function called_by_wasm() {
  try {
    wasm_module.exports.function_that_throws_exception();
  } catch(e) {
    saved_exception = e
    throw e
  }
}

function call_wasm() {
  try {
    wasm_module.exports.function_that_calls_called_by_wasm();
  } catch (e) {
    console.info(e === saved_exception)
  }
}

Let's assume that wasm_module.exports.function_that_calls_called_by_wasm either does not contain a catch block or catches and rethrows the exception.

Should the console.info line be guaranteed to print true?

One could imagine an implementation strategy for rethrow that reconstructs an equivalent exception rather than throwing the exact same one. Do we want to require rethrow to reuse the same exception object?

I think this constraint would only apply to the JavaScript embedding. I imagine there exist platforms where "reuse the same exception object" doesn't mean much.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions