Repository navigation
Expand file tree
/
Copy pathindex.md
More file actions
69 lines (52 loc) · 2.63 KB
/
Copy pathindex.md
File metadata and controls
69 lines (52 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
---
title: WebAssembly.CompileError
slug: WebAssembly/Reference/JavaScript_interface/CompileError
l10n:
sourceCommit: 006c05b688814b45a01ad965bbe4ebfc15513e74
---
**`WebAssembly.CompileError`** 对象表示 WebAssembly 解码或验证期间的错误。
## 构造函数
- [`WebAssembly.CompileError()`](/zh-CN/docs/WebAssembly/Reference/JavaScript_interface/CompileError/CompileError)
- : 创建一个新的 `WebAssembly.CompileError` 对象。
## 实例属性
- {{jsxref("Error.prototype.message", "WebAssembly.CompileError.prototype.message")}}
- : 错误消息。继承自 {{jsxref("Error")}}。
- {{jsxref("Error.prototype.name", "WebAssembly.CompileError.prototype.name")}}
- : 错误名字。继承自 {{jsxref("Error")}}。
- {{jsxref("Error.prototype.cause", "WebAssembly.CompileError.prototype.cause")}}
- : 错误原因。继承自 {{jsxref("Error")}}。
- {{jsxref("Error.prototype.fileName", "WebAssembly.CompileError.prototype.fileName")}} {{non-standard_inline}}
- : 引发此错误的文件的路径。继承自 {{jsxref("Error")}}。
- {{jsxref("Error.prototype.lineNumber", "WebAssembly.CompileError.prototype.lineNumber")}} {{non-standard_inline}}
- : 引发此错误的代码所在的文件的行号。继承自 {{jsxref("Error")}}。
- {{jsxref("Error.prototype.columnNumber", "WebAssembly.CompileError.prototype.columnNumber")}} {{non-standard_inline}}
- : 引发此错误的代码在文件中所在行的列号。继承自 {{jsxref("Error")}}。
- {{jsxref("Error.prototype.stack", "WebAssembly.CompileError.prototype.stack")}} {{non-standard_inline}}
- : 堆栈跟踪。继承自 {{jsxref("Error")}}。
## 实例方法
- {{jsxref("Error.prototype.toString", "WebAssembly.CompileError.prototype.toString()")}}
- : 返回一个表示指定的 `Error` 对象的字符串。继承自 {{jsxref("Error")}}。
## 示例
### 创建一个新的 CompileError 实例
下面的片段创建一个新的 `CompileError` 实例,并将其详细信息打印到控制台:
```js
try {
throw new WebAssembly.CompileError("你好", "某个文件", 10);
} catch (e) {
console.log(e instanceof CompileError); // true
console.log(e.message); // "你好"
console.log(e.name); // "CompileError"
console.log(e.fileName); // "某个文件"
console.log(e.lineNumber); // 10
console.log(e.columnNumber); // 0
console.log(e.stack); // 返回运行代码的位置
}
```
## 规范
{{Specifications}}
## 浏览器兼容性
{{Compat}}
## 参见
- [WebAssembly](/zh-CN/docs/WebAssembly) 概览
- [WebAssembly 概念](/zh-CN/docs/WebAssembly/Guides/Concepts)
- [使用 WebAssembly JavaScript API](/zh-CN/docs/WebAssembly/Guides/Using_the_JavaScript_API)