mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-07-31 03:51:56 +00:00
Improving the code generation for catch (#2098)
* Improving the code generation for catch * Fixing newlines * Running rustfmt * Updating unit tests * Fixing build error
This commit is contained in:
@@ -24,9 +24,16 @@ function addToAnyrefTable0(obj) {
|
||||
return idx;
|
||||
}
|
||||
|
||||
function handleError(e) {
|
||||
const idx = addToAnyrefTable0(e);
|
||||
wasm.__wbindgen_exn_store(idx);
|
||||
function handleError(f) {
|
||||
return function () {
|
||||
try {
|
||||
return f.apply(this, arguments);
|
||||
|
||||
} catch (e) {
|
||||
const idx = addToAnyrefTable0(e);
|
||||
wasm.__wbindgen_exn_store(idx);
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
*/
|
||||
@@ -34,13 +41,9 @@ export function exported() {
|
||||
wasm.exported();
|
||||
}
|
||||
|
||||
export const __wbg_foo_8d66ddef0ff279d6 = function() {
|
||||
try {
|
||||
foo();
|
||||
} catch (e) {
|
||||
handleError(e)
|
||||
}
|
||||
};
|
||||
export const __wbg_foo_8d66ddef0ff279d6 = handleError(function() {
|
||||
foo();
|
||||
});
|
||||
|
||||
export const __wbindgen_throw = function(arg0, arg1) {
|
||||
throw new Error(getStringFromWasm0(arg0, arg1));
|
||||
|
@@ -29,8 +29,15 @@ function addHeapObject(obj) {
|
||||
return idx;
|
||||
}
|
||||
|
||||
function handleError(e) {
|
||||
wasm.__wbindgen_exn_store(addHeapObject(e));
|
||||
function handleError(f) {
|
||||
return function () {
|
||||
try {
|
||||
return f.apply(this, arguments);
|
||||
|
||||
} catch (e) {
|
||||
wasm.__wbindgen_exn_store(addHeapObject(e));
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
*/
|
||||
@@ -42,13 +49,9 @@ export const __wbindgen_object_drop_ref = function(arg0) {
|
||||
takeObject(arg0);
|
||||
};
|
||||
|
||||
export const __wbg_foo_8d66ddef0ff279d6 = function() {
|
||||
try {
|
||||
foo();
|
||||
} catch (e) {
|
||||
handleError(e)
|
||||
}
|
||||
};
|
||||
export const __wbg_foo_8d66ddef0ff279d6 = handleError(function() {
|
||||
foo();
|
||||
});
|
||||
|
||||
export const __wbindgen_rethrow = function(arg0) {
|
||||
throw takeObject(arg0);
|
||||
|
Reference in New Issue
Block a user