aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/webassembly/runtimeerror
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/javascript/reference/global_objects/webassembly/runtimeerror
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/webassembly/runtimeerror')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/webassembly/runtimeerror/index.html111
1 files changed, 111 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/runtimeerror/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/runtimeerror/index.html
new file mode 100644
index 0000000000..3962917a9e
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/runtimeerror/index.html
@@ -0,0 +1,111 @@
+---
+title: WebAssembly.RuntimeError()
+slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError
+translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError
+---
+<div>{{JSRef}}</div>
+
+<p><code><strong>WebAssembly.RuntimeError()</strong></code>构造函数创建一个新的WebAssembly RuntimeError对象---一个每当WebAssembly陷入指定陷阱时将抛出的类型。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox">new WebAssembly.RuntimeError(<var>message</var>, <var>fileName</var>, <var>lineNumber</var>)</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>message</code> {{optional_inline}}</dt>
+ <dd>有可读性的错误信息。</dd>
+ <dt><code>fileName</code> {{optional_inline}}{{non-standard_inline}}</dt>
+ <dd>包含导致异常的代码的文件名。</dd>
+ <dt><code>lineNumber</code> {{optional_inline}}{{non-standard_inline}}</dt>
+ <dd>导致异常的代码的行号。</dd>
+</dl>
+
+<h2 id="属性">属性</h2>
+
+<p><em><code>RuntimeError</code>构造函数不包含其自身特有的属性,但是,它确实通过原型链继承了某些属性。</em></p>
+
+<dl>
+ <dt><code>WebAssembly.RuntimeError.prototype.constructor</code></dt>
+ <dd>创建示例原型的特定函数。</dd>
+ <dt>{{jsxref("Error.prototype.message", "WebAssembly.RuntimeError.prototype.message")}}</dt>
+ <dd>错误信息。 尽管ECMA-262指定{{jsxref("URIError")}}应提供自己的<code>message</code>属性,但在<a href="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey">SpiderMonkey</a>中,它继承了{{jsxref("Error.prototype.message")}}。</dd>
+ <dt>{{jsxref("Error.prototype.name", "WebAssembly.RuntimeError.prototype.name")}}</dt>
+ <dd>错误名称。继承自 {{jsxref("Error")}}.</dd>
+ <dt>{{jsxref("Error.prototype.fileName", "WebAssembly.RuntimeError.prototype.fileName")}}</dt>
+ <dd>报出错误的文件路径。继承自 {{jsxref("Error")}}.</dd>
+ <dt>{{jsxref("Error.prototype.lineNumber", "WebAssembly.RuntimeError.prototype.lineNumber")}}</dt>
+ <dd>报出错误的代码所在文件中的行数。继承自{{jsxref("Error")}}.</dd>
+ <dt>{{jsxref("Error.prototype.columnNumber", "WebAssembly.RuntimeError.prototype.columnNumber")}}</dt>
+ <dd>报出错误的代码所在文件中的列数。继承自 {{jsxref("Error")}}.</dd>
+ <dt>{{jsxref("Error.prototype.stack", "WebAssembly.RuntimeError.prototype.stack")}}</dt>
+ <dd>堆栈跟踪。 继承自 {{jsxref("Error")}}.</dd>
+</dl>
+
+<h2 id="方法">方法</h2>
+
+<p><em><code>RuntimeError</code>构造函数不包含自己的方法,但是,它确实通过原型链继承了一些方法。</em></p>
+
+<dl>
+ <dt>{{jsxref("Error.prototype.toSource", "WebAssembly.RuntimeError.prototype.toSource()")}}</dt>
+ <dd>返回可能导致相同错误的代码。 继承自{{jsxref("Error")}}.</dd>
+ <dt>{{jsxref("Error.prototype.toString", "WebAssembly.RuntimeError.prototype.toString()")}}</dt>
+ <dd>返回表示代表指定的<code>Error</code>对象的字符串。从{{jsxref("Error")}}.</dd>
+</dl>
+
+<h2 id="样例">样例</h2>
+
+<p>以下代码段创建了一个新的RuntimeError实例,并将其详细信息记录到控制台:</p>
+
+<pre class="brush: js">try {
+ throw new WebAssembly.RuntimeError('Hello', 'someFile', 10);
+} catch (e) {
+ console.log(e instanceof RuntimeError); // true
+ console.log(e.message); // "Hello"
+ console.log(e.name); // "RuntimeError"
+ console.log(e.fileName); // "someFile"
+ console.log(e.lineNumber); // 10
+ console.log(e.columnNumber); // 0
+ console.log(e.stack); // 返回代码运行的位置
+}</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('WebAssembly JS', '#constructor-properties-of-the-webassembly-object', 'WebAssembly constructors')}}</td>
+ <td>{{Spec2('WebAssembly JS')}}</td>
+ <td>Initial WebAssembly draft definition.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-native-error-types-used-in-this-standard', 'NativeError')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td>Definition of standard NativeError types.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2>
+
+<div>
+
+
+<p>{{Compat("javascript.builtins.WebAssembly.RuntimeError")}}</p>
+</div>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li><a href="/en-US/docs/WebAssembly">WebAssembly</a> overview page</li>
+ <li><a href="/en-US/docs/WebAssembly/Concepts">WebAssembly concepts</a></li>
+ <li><a href="/en-US/docs/WebAssembly/Using_the_JavaScript_API">Using the WebAssembly JavaScript API</a></li>
+</ul>