diff options
| author | t7yang <t7yang@gmail.com> | 2022-01-10 08:38:07 +0800 |
|---|---|---|
| committer | Irvin <irvinfly@gmail.com> | 2022-02-16 02:35:54 +0800 |
| commit | c40612041809fe289aba58aefa170bbe784aba1f (patch) | |
| tree | 8ca89b071d04afcf7abd6d9a04d0765a041d9c8a /files/zh-cn/web/javascript/reference/global_objects/error | |
| parent | 12a899ab8540bc84f56a0dc6491be80a48499d49 (diff) | |
| download | translated-content-c40612041809fe289aba58aefa170bbe784aba1f.tar.gz translated-content-c40612041809fe289aba58aefa170bbe784aba1f.tar.bz2 translated-content-c40612041809fe289aba58aefa170bbe784aba1f.zip | |
remove name attribute for zh-CN
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/error')
4 files changed, 26 insertions, 26 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/error/index.html b/files/zh-cn/web/javascript/reference/global_objects/error/index.html index fe9ad2deed..82acc4e18f 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/error/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/error/index.html @@ -11,11 +11,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Error <p>通过<strong>Error</strong>的构造器可以创建一个错误对象。当运行时错误产生时,Error的实例对象会被抛出。Error对象也可用于用户自定义的异常的基础对象。下面列出了各种内建的标准错误类型。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="brush: js">new Error([<em>message</em>[, <em>fileName</em>[,<em>lineNumber</em>]]])</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>message</code></dt> @@ -32,7 +32,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Error <dd>可选。被创建的Error对象的lineNumber属性值。默认是调用Error构造器代码所在的文件的行号。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>当代码运行时的发生错误,会创建新的<code>Error</code> 对象,并将其抛出。</p> @@ -47,7 +47,7 @@ const x = Error('I was created using a function call!'); // has the same functionality as this: const y = new Error('I was constructed via the "new" keyword!');</code></pre> -<h3 id="Error_types" name="Error_types">Error 类型</h3> +<h3 id="Error_types">Error 类型</h3> <p>除了通用的Error构造函数外,JavaScript还有6个其他类型的错误构造函数。更多客户端异常,详见 <a href="/en/JavaScript/Guide/Statements#Exception_Handling_Statements" title="en/JavaScript/Guide/Statements#Exception Handling Statements">Exception Handling Statements</a>。</p> @@ -83,18 +83,18 @@ const y = new Error('I was constructed via the "new" keyword!');</code></pre> <dd>创建一个error实例,表示错误的原因:给 {{jsxref("Global_Objects/encodeURI", "encodeURI()")}}或 {{jsxref("Global_Objects/decodeURI", "decodeURI()")}}传递的参数无效。</dd> </dl> -<h2 id="Properties" name="Properties">属性</h2> +<h2 id="Properties">属性</h2> <dl> <dt>{{jsxref("Error.prototype")}}</dt> <dd>允许添加属性到<code>Error</code>实例。</dd> </dl> -<h2 id="Methods" name="Methods">方法</h2> +<h2 id="Methods">方法</h2> <p>全局<code>Error</code>对象自身不包含任何方法,但从原型链中继承了一些方法.</p> -<h2 id="Error_instances" name="Error_instances"><code>Error</code> 实例</h2> +<h2 id="Error_instances"><code>Error</code> 实例</h2> <div> <p>{{page('en-US/docs/JavaScript/Reference/Global_Objects/Error/prototype', 'Description')}}</p> @@ -108,9 +108,9 @@ const y = new Error('I was constructed via the "new" keyword!');</code></pre> <p>{{page('en-US/docs/JavaScript/Reference/Global_Objects/Error/prototype', 'Methods')}}</p> </div> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example_Throwing_a_generic_error" name="Example:_Throwing_a_generic_error">抛出一个基本错误</h3> +<h3 id="Example_Throwing_a_generic_error">抛出一个基本错误</h3> <p>通常你会使用{{jsxref("Statements/throw", "throw")}}关键字来抛出你创建的Error对象。可以使用 {{jsxref("Statements/try...catch", "try...catch")}} 结构来处理异常:</p> @@ -121,7 +121,7 @@ const y = new Error('I was constructed via the "new" keyword!');</code></pre> } </pre> -<h3 id="Example_Handling_a_specific_error" name="Example:_Handling_a_specific_error">处理一个特定错误</h3> +<h3 id="Example_Handling_a_specific_error">处理一个特定错误</h3> <p>你可以通过判断异常的类型来特定处理某一类的异常,即判断 {{jsxref("Object.prototype.constructor", "constructor")}} 属性,当使用现代Javascript引擎时,可使用{{jsxref("Operators/instanceof", "instanceof")}} 关键字:</p> @@ -248,7 +248,7 @@ try { <div>{{Compat("javascript.builtins.Error")}}</div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Error.prototype")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/error/message/index.html b/files/zh-cn/web/javascript/reference/global_objects/error/message/index.html index e846ff838c..ff4dce9d23 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/error/message/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/error/message/index.html @@ -5,19 +5,19 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Error/message --- <div>{{JSRef("Global_Objects", "Error", "EvalError,InternalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>message</strong></code> 属性是有关错误信息,人类易读的(human-readable)描述。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果该属性已经被设置,则该属性包含了错误的一个简短描述。<a href="/en-US/docs/Mozilla/Projects/SpiderMonkey">SpiderMonkey</a> 大量应用 <code>message</code> 属性在异常方面。 <code>message</code> 属性结合 {{jsxref("Error.prototype.name", "name")}} 属性一起被 {{jsxref("Error.prototype.toString()")}} 方法用来创建错误的字符串形式。</p> <p>默认情况下,<code>message</code> 属性是一个空字符串,但是可以通过指定一段信息作为 {{jsxref("Error", "Error constructor")}} 的第一个参数创建一个实例来改变该属性值。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example:_Throwing_a_custom_error" name="Example:_Throwing_a_custom_error">例子:抛出一个自定义错误</h3> +<h3 id="Example:_Throwing_a_custom_error">例子:抛出一个自定义错误</h3> <pre class="brush: js">var e = new Error("Could not parse input"); // e.message is "Could not parse input" throw e; @@ -102,7 +102,7 @@ throw e; </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Error.prototype.name")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/error/name/index.html b/files/zh-cn/web/javascript/reference/global_objects/error/name/index.html index 0903c6e059..80848f54dc 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/error/name/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/error/name/index.html @@ -5,17 +5,17 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Error/name --- <p>{{JSRef("Global_Objects", "Error", "EvalError,InternalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError")}}</p> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>name</strong></code> 属性表示error类型的名称.初始值为"Error".</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>默认情况下,{{jsxref("Error")}}对象的<code>name</code>属性值为"Error".<code>name属性和</code>{{jsxref("Error.prototype.message", "message")}}属性一起,通过调用{{jsxref("Error.prototype.toString()")}}方法,会作为最后异常信息的字符串表示.</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example:_Throwing_a_custom_error" name="Example:_Throwing_a_custom_error">例子: 抛出一个自定义错误</h3> +<h3 id="Example:_Throwing_a_custom_error">例子: 抛出一个自定义错误</h3> <pre class="brush:js">var e = new Error("Malformed input"); // e.name默认是"Error" @@ -102,7 +102,7 @@ throw e; // "ParseError: Malformed input" </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Error.prototype.message")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/error/tostring/index.html b/files/zh-cn/web/javascript/reference/global_objects/error/tostring/index.html index a7e6a10ace..395d61aee2 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/error/tostring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/error/tostring/index.html @@ -5,11 +5,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Error/toString --- <div> {{JSRef("Global_Objects", "Error", "EvalError,InternalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>toString()</strong></code> 方法返回一个指定的错误对象(Error object)的字符串表示。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>e</em>.toString();</code></pre> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>{{jsxref("Error")}} 对象覆盖了 {{jsxref("Object.prototype.toString()")}} 方法。该方法实现如下:(假定 <code>Object</code> 和 <code>String</code> 没有被更改):</p> <pre class="brush:js">Error.prototype.toString = function() { @@ -33,7 +33,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Error/toString return name + ": " + msg; }; </pre> -<h2 id="Example" name="Example">示例</h2> +<h2 id="Example">示例</h2> <pre class="brush:js">var e = new Error("fatal error"); print(e.toString()); // "Error: fatal error" @@ -123,7 +123,7 @@ print(e.toString()); // "hello" </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Error.prototype.toSource()")}}</li> </ul> |
