--- title: WebAssembly.CompileError() slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError ---
WebAssembly.CompileError()
构造函数创建一个新的WebAssembly CompileError
对象,该对象表示WebAssembly解码或验证期间的错误。
new WebAssembly.CompileError(message, fileName, lineNumber)
message
{{optional_inline}}fileName
{{optional_inline}}{{non-standard_inline}}lineNumber
{{optional_inline}}{{non-standard_inline}}CompileError
构造函数没有一些它特有的属性,但是,它确实通过原型链继承了某些属性。
WebAssembly.CompileError.prototype.constructor
message
属性,但在SpiderMonkey中,它继承了 {{jsxref("Error.prototype.message")}}。CompileError
构造函数不包含自己的方法,但是,它确实通过原型链继承了一些方法。
Error
对象的字符串。从 {{jsxref("Error")}}继承。以下代码段创建一个新的CompileError实例,并将其详细信息记录到控制台:
try { throw new WebAssembly.CompileError('Hello', 'someFile', 10); } catch (e) { console.log(e instanceof CompileError); // true console.log(e.message); // "Hello" console.log(e.name); // "CompileError" console.log(e.fileName); // "someFile" console.log(e.lineNumber); // 10 console.log(e.columnNumber); // 0 console.log(e.stack); // 返回代码运行的位置 }
Specification | Status | Comment |
---|---|---|
{{SpecName('WebAssembly JS', '#constructor-properties-of-the-webassembly-object', 'WebAssembly constructors')}} | {{Spec2('WebAssembly JS')}} | Initial WebAssembly draft definition. |
{{SpecName('ESDraft', '#sec-native-error-types-used-in-this-standard', 'NativeError')}} | {{Spec2('ESDraft')}} | Definition of standard NativeError types. |
{{Compat("javascript.builtins.WebAssembly.CompileError")}}