Tests/LibWasm: Handle all stream errors in parse_webassembly_module

This commit is contained in:
Ali Mohammad Pur 2021-08-30 17:30:18 +04:30 committed by Andreas Kling
parent 2c7e2e351a
commit 30a1a25daa
Notes: sideshowbarker 2024-07-18 05:03:52 +09:00

View File

@ -104,6 +104,11 @@ TESTJS_GLOBAL_FUNCTION(parse_webassembly_module, parseWebAssemblyModule)
}
auto& array = static_cast<JS::Uint8Array&>(*object);
InputMemoryStream stream { array.data() };
ScopeGuard handle_stream_error {
[&] {
stream.handle_any_error();
}
};
auto result = Wasm::Module::parse(stream);
if (result.is_error()) {
vm.throw_exception<JS::SyntaxError>(global_object, Wasm::parse_error_to_string(result.error()));