mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-12 01:34:04 +08:00
102 lines
6.5 KiB
HTML
102 lines
6.5 KiB
HTML
<article id="wikiArticle">
|
||
<p></p><p></p>
|
||
<h2 id="Summary" name="Summary">概述</h2>
|
||
<p><code style="font-style: normal; line-height: 19.0909080505371px;"><strong>name</strong></code><span style="line-height: 19.0909080505371px;"> </span>属性表示error类型的名称.初始值为"Error".</p>
|
||
<h2 id="Description" name="Description">描述</h2>
|
||
<p>默认情况下,<span style="line-height: 19.0909080505371px;"><a href="Reference/Global_Objects/Error" title="通过Error的构造器可以创建一个错误对象。当运行时错误产生时,Error的实例对象会被抛出。Error对象也可用于用户自定义的异常的基础对象。下面列出了各种内建的标准错误类型。"><code>Error</code></a></span>对象的<code>name</code>属性值为"Error".<code>name属性和</code><span style="line-height: 19.0909080505371px;"><a href="Reference/Global_Objects/Error/message" title="message 属性是有关错误信息,人类易读的(human-readable)描述。"><code>message</code></a></span>属性一起,通过调用<span style="line-height: 19.0909080505371px;"><a href="Reference/Global_Objects/Error/toString" title="toString() 方法返回一个指定的错误对象(Error object)的字符串表示。"><code>Error.prototype.toString()</code></a></span>方法,会作为最后异常信息的字符串表示.</p>
|
||
<h2 id="Examples" name="Examples">示例</h2>
|
||
<h3 id="Example:_Throwing_a_custom_error" name="Example:_Throwing_a_custom_error">例子: 抛出一个自定义错误</h3>
|
||
<pre><code class="language-js">var e = new Error("Malformed input"); // e.name默认是"Error"
|
||
|
||
e.name = "ParseError"; // 修改之后,e.toString()会成为下面这样的字符串
|
||
throw e; // "ParseError: Malformed input"
|
||
</code></pre>
|
||
<h2 id="规范" style="margin-bottom: 20px; line-height: 30px; font-size: 2.14285714285714rem;">规范</h2>
|
||
<table class="standard-table" style="line-height: 19.0909080505371px;">
|
||
<tbody>
|
||
<tr>
|
||
<th scope="col">Specification</th>
|
||
<th scope="col">Status</th>
|
||
<th scope="col">Comment</th>
|
||
</tr>
|
||
<tr>
|
||
<td>ECMAScript 1st Edition.</td>
|
||
<td>Standard</td>
|
||
<td>Initial definition.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><a class="external" href="https://www.ecma-international.org/ecma-262/5.1/#sec-15.11.4.2" hreflang="en" lang="en" rel="noopener">ECMAScript 5.1 (ECMA-262)<br/><small lang="zh-CN">Error.prototype.name</small></a></td>
|
||
<td><span class="spec-Standard">Standard</span></td>
|
||
<td> </td>
|
||
</tr>
|
||
<tr>
|
||
<td><a class="external" href="https://www.ecma-international.org/ecma-262/6.0/#sec-error.prototype.name" hreflang="en" lang="en" rel="noopener">ECMAScript 2015 (6th Edition, ECMA-262)<br/><small lang="zh-CN">Error.prototype.name</small></a></td>
|
||
<td><span class="spec-Standard">Standard</span></td>
|
||
<td> </td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<h2 id="浏览器兼容性" style="margin-bottom: 20px; line-height: 30px; font-size: 2.14285714285714rem;">浏览器兼容性</h2>
|
||
<div style="line-height: 19.0909080505371px;"><div class="blockIndicator warning"><strong><a class="external" href="https://github.com/mdn/browser-compat-data" rel="noopener">We're converting our compatibility data into a machine-readable JSON format</a></strong>.
|
||
This compatibility table still uses the old format,
|
||
because we haven't yet converted the data it contains.
|
||
<strong><a class="new" href="/zh-CN/docs/MDN/Contribute/Structures/Compatibility_tables" rel="nofollow">Find out how you can help!</a></strong></div>
|
||
<div class="htab">
|
||
<a id="AutoCompatibilityTable" name="AutoCompatibilityTable"></a>
|
||
<ul>
|
||
<li class="selected"><a>Desktop</a></li>
|
||
<li><a>Mobile</a></li>
|
||
</ul>
|
||
</div></div>
|
||
<div id="compat-desktop" style="line-height: 19.0909080505371px;">
|
||
<table class="compat-table" style="border-color: transparent;">
|
||
<tbody>
|
||
<tr>
|
||
<th style="line-height: 16px;">Feature</th>
|
||
<th style="line-height: 16px;">Chrome</th>
|
||
<th style="line-height: 16px;">Firefox (Gecko)</th>
|
||
<th style="line-height: 16px;">Internet Explorer</th>
|
||
<th style="line-height: 16px;">Opera</th>
|
||
<th style="line-height: 16px;">Safari</th>
|
||
</tr>
|
||
<tr>
|
||
<td>Basic support</td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<div id="compat-mobile" style="line-height: 19.0909080505371px;">
|
||
<table class="compat-table" style="border-color: transparent;">
|
||
<tbody>
|
||
<tr>
|
||
<th style="line-height: 16px;">Feature</th>
|
||
<th style="line-height: 16px;">Android</th>
|
||
<th style="line-height: 16px;">Chrome for Android</th>
|
||
<th style="line-height: 16px;">Firefox Mobile (Gecko)</th>
|
||
<th style="line-height: 16px;">IE Mobile</th>
|
||
<th style="line-height: 16px;">Opera Mobile</th>
|
||
<th style="line-height: 16px;">Safari Mobile</th>
|
||
</tr>
|
||
<tr>
|
||
<td>Basic support</td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
<td><span style="color: #888;" title="Please update this with the earliest version of support.">(Yes)</span></td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<h2 id="See_also" name="See_also" style="margin-bottom: 20px; line-height: 30px; font-size: 2.14285714285714rem;">相关链接</h2>
|
||
<ul style="line-height: 19.0909080505371px;">
|
||
<li><a href="Reference/Global_Objects/Error/message" title="message 属性是有关错误信息,人类易读的(human-readable)描述。"><code>Error.prototype.message</code></a></li>
|
||
<li><a href="Reference/Global_Objects/Error/toString" title="toString() 方法返回一个指定的错误对象(Error object)的字符串表示。"><code>Error.prototype.toString()</code></a></li>
|
||
</ul>
|
||
</article> |