WebAssembly.LinkError()

WebAssembly.LinkError() 构造器创建一个新的WebAssembly LinkError 对象, 该对象表明一个模块创建时(besides traps from the start function)发生的错误.

 

句法

new WebAssembly.LinkError(message, fileName, lineNumber)

Parameters

message 可选
自然语言对错误的描述.
fileName 可选
包含抛出异常代码的代码文件名.
lineNumber 可选
抛出异常的代码行号.

Properties

LinkError 不包含自己独立的属性, 它仅仅继承了原型链上的属性.

WebAssembly.LinkError.prototype.constructor
指明创建该实体的构造函数.
WebAssembly.LinkError.prototype.message
Error message. Although ECMA-262 specifies that URIError should provide its own message property, in SpiderMonkey, it inherits Error.prototype.message.
WebAssembly.LinkError.prototype.name
Error name. Inherited from Error.
WebAssembly.LinkError.prototype.fileName
Path to file that raised this error. Inherited from Error.
WebAssembly.LinkError.prototype.lineNumber
Line number in file that raised this error. Inherited from Error.
WebAssembly.LinkError.prototype.columnNumber
Column number in line that raised this error. Inherited from Error.
WebAssembly.LinkError.prototype.stack
Stack trace. Inherited from Error.

Methods

The LinkError constructor contains no methods of its own, however, it does inherit some methods through the prototype chain.

WebAssembly.LinkError.prototype.toSource()
返回可以执行并得到与该错误对象相同的源代码.
WebAssembly.LinkError.prototype.toString()
返回一个可以说明该 Error 对象的文字. 继承自  Error.

Examples

下列代码片段创建了一个新的 LinkError 实例, 并将其打印到控制台:

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
}

Specifications

Specification Status Comment
WebAssembly JavaScript Interface
WebAssembly constructors
Working Draft Initial WebAssembly draft definition.
ECMAScript Latest Draft (ECMA-262)
NativeError
Draft Definition of standard NativeError types.

Browser compatibility

Update compatibility data on GitHub
Desktop Mobile Server
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet Node.js
LinkError Chrome Full support 57 Edge Full support 16 Firefox Full support 52
Notes
Full support 52
Notes
Notes Disabled in the Firefox 52 Extended Support Release (ESR).
IE No support No Opera Full support 44 Safari Full support 11 WebView Android Full support 57 Chrome Android Full support 57 Firefox Android Full support 52
Notes
Full support 52
Notes
Notes Disabled in the Firefox 52 Extended Support Release (ESR).
Opera Android ? Safari iOS Full support 11 Samsung Internet Android Full support 7.0 nodejs Full support 8.0.0

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
See implementation notes.
See implementation notes.

See also