首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

WebAssembly.linkError

这是一项 实验技术

在使用此产品之前,请仔细检查浏览器兼容性表。

WebAssembly.LinkError()构造函数创建一个新WebAssembly LinkError对象,模块实例化期间指示错误(除了陷阱从启动功能)。

语法

代码语言:javascript
复制
new WebAssembly.LinkError(message, fileName, lineNumber)

参数

message可选,人类可读的错误描述。fileName可选,包含导致异常的代码的文件的名称。lineNumber可选,导致异常的代码的行号。

属性

LinkError构造函数中包含没有自己的独特性,但是,它会通过继承原型链中的某些属性。

WebAssembly.LinkError.prototype.constructor指定创建实例原型的函数。WebAssembly.LinkError.prototype.message错误信息。虽然ECMA-262规定URIError应该提供自己的message财产,在SpiderMonkey中,它继承Error.prototype.messageWebAssembly.LinkError.prototype.name错误名称。继承ErrorWebAssembly.LinkError.prototype.fileName引发此错误的文件路径。继承ErrorWebAssembly.LinkError.prototype.lineNumber引发此错误的文件中的行号。继承ErrorWebAssembly.LinkError.prototype.columnNumber引发此错误的列号。继承ErrorWebAssembly.LinkError.prototype.stack堆栈跟踪。继承Error

方法

LinkError构造不包含它自己的方法,但是,它会继承原型链的一些方法。

WebAssembly.LinkError.prototype.toSource()返回可能评估相同错误的代码。继承ErrorWebAssembly.LinkError.prototype.toString()返回表示指定Error对象的字符串。继承自Error

示例

以下片段创建一个新LinkError实例,并将其详细信息记录到控制台:

代码语言:javascript
复制
try {
  throw new WebAssembly.LinkError('Hello', 'someFile', 10);
} catch (e) {
  console.log(e instanceof LinkError); // true
  console.log(e.message);                 // "Hello"
  console.log(e.name);                    // "LinkError"
  console.log(e.fileName);                // "someFile"
  console.log(e.lineNumber);              // 10
  console.log(e.columnNumber);            // 0
  console.log(e.stack);                   // returns the location where the code was run
}

规范

Specification

Status

Comment

Web Assembly JavaScript APIThe definition of 'WebAssembly constructors' in that specification.

Draft

Initial WebAssembly draft definition.

ECMAScript Latest Draft (ECMA-262)The definition of 'NativeError' in that specification.

Living Standard

Definition of standard NativeError types.

浏览器兼容性

Feature

Chrome

Edge

Firefox

Internet Explorer

Opera

Safari

Basic Support

57

16

522

No

44

11

Feature

Android

Chrome for Android

Edge mobile

Firefox for Android

IE mobile

Opera Android

iOS Safari

Basic Support

57

57

(Yes)1

522

No

?

11

扫码关注腾讯云开发者

领取腾讯云代金券