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 ownmessage
property, in SpiderMonkey, it inheritsError.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 }