WebAssembly.CompileError()
**WebAssembly.CompileError()**构造函数创建一个新的 WebAssembly CompileError对象,该对象表示 WebAssembly 解码或验证期间的错误。
语法
new WebAssembly.CompileError(message, fileName, lineNumber)
参数
message可选- 
    
有可读性的错误描述。
 fileName可选 非标准- 
    
包含导致异常的代码的文件名。
 lineNumber可选 非标准- 
    
导致异常的代码的行号。
 
属性
CompileError构造函数没有一些它特有的属性,但是,它确实通过原型链继承了某些属性。
WebAssembly.CompileError.prototype.constructor- 
    
创建示例原型的特定函数。
 WebAssembly.CompileError.prototype.message- 
    
错误信息。尽管 ECMA-262 指定
URIError应提供自己的message属性,但在SpiderMonkey中,它继承了Error.prototype.message。 WebAssembly.CompileError.prototype.name- 
    
错误名称。继承自
Error。 WebAssembly.CompileError.prototype.fileName- 
    
报出错误的文件名。继承自
Error。 WebAssembly.CompileError.prototype.lineNumber- 
    
报出错误的代码所在文件中的行数。继承自
Error。 WebAssembly.CompileError.prototype.columnNumber- 
    
报出错误的代码所在文件中的列数。继承自
Error。 WebAssembly.CompileError.prototype.stack- 
    
堆栈跟踪。继承自
Error。 
方法
CompileError构造函数不包含自己的方法,但是,它确实通过原型链继承了一些方法。
WebAssembly.CompileError.prototype.toSource()- 
    
返回可能导致相同错误的代码。继承自
Error。 WebAssembly.CompileError.prototype.toString()- 
    
返回表示代表指定的
Error对象的字符串。从Error继承。 
示例
以下代码段创建一个新的 CompileError 实例,并将其详细信息记录到控制台:
js
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 | 
|---|
| WebAssembly JavaScript Interface  # exceptiondef-compileerror  | 
| ECMAScript Language Specification  # sec-native-error-types-used-in-this-standard  | 
浏览器兼容性
BCD tables only load in the browser