diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/javascript/reference/global_objects/webassembly/compileerror | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-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/compileerror')
-rw-r--r-- | files/zh-cn/web/javascript/reference/global_objects/webassembly/compileerror/index.html | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/compileerror/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/compileerror/index.html new file mode 100644 index 0000000000..179b8589a2 --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/compileerror/index.html @@ -0,0 +1,114 @@ +--- +title: WebAssembly.CompileError() +slug: Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError +translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError +--- +<div>{{JSRef}}</div> + +<p><code><strong>WebAssembly.CompileError()</strong></code>构造函数创建一个新的WebAssembly <code>CompileError</code>对象,该对象表示WebAssembly解码或验证期间的错误。</p> + +<h2 id="语法">语法</h2> + +<pre class="syntaxbox"><code>new WebAssembly.CompileError(<var>message</var>, <var>fileName</var>, <var>lineNumber</var>)</code></pre> + +<h3 id="参数">参数</h3> + +<dl> + <dt><code>message</code> {{optional_inline}}</dt> + <dd><span class="tlid-translation translation" lang="zh-CN"><span title="">有可读性的错误描述。</span></span></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>CompileError</code>构造函数没有一些它特有的属性,但是,它确实通过原型链继承了某些属性。</em></p> + +<dl> + <dt><code>WebAssembly.CompileError.prototype.constructor</code></dt> + <dd>创建示例原型的特定函数。</dd> + <dt>{{jsxref("Error.prototype.message", "WebAssembly.CompileError.prototype.message")}}</dt> + <dd>错误信息。 尽管ECMA-262指定{{jsxref("URIError")}}应提供自己的<code>message</code>属性,但在<a href="/en-US/docs/Mozilla/Projects/SpiderMonkey">SpiderMonkey</a>中,它继承了 {{jsxref("Error.prototype.message")}}。</dd> + <dt>{{jsxref("Error.prototype.name", "WebAssembly.CompileError.prototype.name")}}</dt> + <dd>错误名称。继承自 {{jsxref("Error")}}。</dd> + <dt>{{jsxref("Error.prototype.fileName", "WebAssembly.CompileError.prototype.fileName")}}</dt> + <dd>报出错误的文件名。继承自 {{jsxref("Error")}}。</dd> + <dt>{{jsxref("Error.prototype.lineNumber", "WebAssembly.CompileError.prototype.lineNumber")}}</dt> + <dd>报出错误的代码所在文件中的行数。继承自 {{jsxref("Error")}}。</dd> + <dt>{{jsxref("Error.prototype.columnNumber", "WebAssembly.CompileError.prototype.columnNumber")}}</dt> + <dd>报出错误的代码所在文件中的列数。继承自 {{jsxref("Error")}}。</dd> + <dt>{{jsxref("Error.prototype.stack", "WebAssembly.CompileError.prototype.stack")}}</dt> + <dd>堆栈跟踪。 继承自{{jsxref("Error")}}。</dd> +</dl> + +<h2 id="方法">方法</h2> + +<p><em><code>CompileError</code>构造函数不包含自己的方法,但是,它确实通过原型链继承了一些方法。</em></p> + +<dl> + <dt>{{jsxref("Error.prototype.toSource", "WebAssembly.CompileError.prototype.toSource()")}}</dt> + <dd>返回可能导致相同错误的代码。 继承自{{jsxref("Error")}}。</dd> + <dt>{{jsxref("Error.prototype.toString", "WebAssembly.CompileError.prototype.toString()")}}</dt> + <dd>返回表示代表指定的<code>Error</code>对象的字符串。从 {{jsxref("Error")}}继承。</dd> +</dl> + +<h2 id="示例">示例</h2> + +<p>以下代码段创建一个新的CompileError实例,并将其详细信息记录到控制台:</p> + +<pre class="brush: js">try { + throw new WebAssembly.CompileError('Hello', 'someFile', 10); +} catch (e) { + console.log(e instanceof CompileError); // true + console.log(e.message); // "Hello" + console.log(e.name); // "CompileError" + 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.CompileError")}}</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> + +<dl> +</dl> |