| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/zh-CN/docs/WebAssembly/Reference/JavaScript_interface/Exception/stack | [Back] [Original] |
Get to know MDN better
:
WebAssembly.Exception stack
WebAssembly
WebAssembly JavaScript options.trackStack=true
WebAssembly
${url}:wasm-function[${funcIndex}]:${pcOffset}
WebAssembly
WebAssembly example.wasm $tagname $throwExnWithStack run throwExnWithStack JavaScript
(module
;; $tagname
(import "extmod" "exttag" (tag $tagname (param i32)))
;; $throwExnWithStack
(import "extmod" "throwExnWithStack" (func $throwExnWithStack (param i32)))
;; 42 $throwExnWithStack
(func (export "run")
i32.const 42
call $throwExnWithStack
)
)
JavaScript tag throwExceptionWithStack WebAssembly importObject WebAssembly
WebAssembly run() catch
const tag = new WebAssembly.Tag({ parameters: ["i32"] });
function throwExceptionWithStack(param) {
// {traceStack: true}
throw new WebAssembly.Exception(tag, [param], { traceStack: true });
}
// importObject WebAssembly import
const importObject = {
extmod: {
exttag: tag,
throwExnWithStack: throwExceptionWithStack,
},
};
WebAssembly.instantiateStreaming(fetch("example.wasm"), importObject)
.then((obj) => {
console.log(obj.instance.exports.run());
})
.catch((e) => {
console.log(`${e.stack}`);
});
//
// throwExceptionWithStack@http://<url>/main.js:76:9
// @http://<url>/example.wasm:wasm-function[3]:0x73
// @http://<url>/main.js:82:38
new WebAssembly.Exception(tag, [param], { traceStack: true });
{traceStack: true} WebAssembly WebAssembly.Exception undefined
| Web Proxy Viewer | New URL | Original Page |