aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/urierror
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/urierror
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/urierror')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/urierror/index.html136
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/urierror/prototype/index.html82
2 files changed, 218 insertions, 0 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/urierror/index.html b/files/zh-cn/web/javascript/reference/global_objects/urierror/index.html
new file mode 100644
index 0000000000..980de3b3c6
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/urierror/index.html
@@ -0,0 +1,136 @@
+---
+title: URIError
+slug: Web/JavaScript/Reference/Global_Objects/URIError
+tags:
+ - Error
+ - JavaScript
+ - URIError
+ - 对象
+translation_of: Web/JavaScript/Reference/Global_Objects/URIError
+---
+<div>{{JSRef}}</div>
+
+<p>URIError 对象用来表示以一种错误的方式使用全局URI处理函数而产生的错误。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox"><code>new URIError([<var>message</var>[, <var>fileName</var>[, <var>lineNumber</var>]]])</code></pre>
+
+<h3 id="参数">参数</h3>
+
+<dl>
+ <dt><code>message</code></dt>
+ <dd>选填。易于理解的错误描述。</dd>
+ <dt><code>fileName</code> 【非标准内联】</dt>
+ <dd>选填。包含造成异常的代码的文件名称。</dd>
+ <dt><code>lineNumber</code> 【非标准内联】</dt>
+ <dd>选填。造成异常的代码行号。</dd>
+</dl>
+
+<h2 id="描述">描述</h2>
+
+<p>当向全局 URI 处理函数传递一个不合法的URI时,URIError 错误会被抛出。</p>
+
+<h2 id="属性">属性</h2>
+
+<dl>
+ <dt>{{jsxref("URIError.prototype")}}</dt>
+ <dd>允许向一个 URIError 对象添加额外的属性。</dd>
+</dl>
+
+<h2 id="方法">方法</h2>
+
+<p>虽然全局 URIError 对象没有任何自己的方法,但是它能通过原型链继承一些方法。</p>
+
+<h2 id="URIError_实例"><code>URIError 实例</code></h2>
+
+<h3 id="属性_2">属性</h3>
+
+<div>{{page('/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/URIError/prototype', '属性')}}</div>
+
+<h3 id="方法_2">方法</h3>
+
+<div>{{page('/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/URIError/prototype', '方法')}}</div>
+
+<h2 id="示例">示例</h2>
+
+<h3 id="捕获一个_URIError_实例">捕获一个 <code>URIError 实例</code></h3>
+
+<pre class="brush: js">try {
+ decodeURIComponent('%');
+} catch (e) {
+ console.log(e instanceof URIError); // true
+ console.log(e.message); // "malformed URI sequence"
+ console.log(e.name); // "URIError"
+ console.log(e.fileName); // "Scratchpad/1"
+ console.log(e.lineNumber); // 2
+ console.log(e.columnNumber); // 2
+ console.log(e.stack); // "@Scratchpad/2:2:3\n"
+}
+</pre>
+
+<h3 id="创建一个_URIError_实例">创建一个 <code>URIError 实例</code></h3>
+
+<pre class="brush: js">try {
+ throw new URIError('Hello', 'someFile.js', 10);
+} catch (e) {
+ console.log(e instanceof URIError); // true
+ console.log(e.message); // "Hello"
+ console.log(e.name); // "URIError"
+ console.log(e.fileName); // "someFile.js"
+ console.log(e.lineNumber); // 10
+ console.log(e.columnNumber); // 0
+ console.log(e.stack); // "@Scratchpad/2:2:9\n"
+}
+</pre>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">注释</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES3', '#sec-15.11.6.6', 'URIError')}}</td>
+ <td>{{Spec2('ES3')}}</td>
+ <td>初始定义</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.11.6.6', 'URIError')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-native-error-types-used-in-this-standard-urierror', 'URIError')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-native-error-types-used-in-this-standard-urierror', 'URIError')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容">浏览器兼容</h2>
+
+<div>
+<div class="hidden">浏览器兼容性表由结构化数据生成。如果你想贡献这部分数据,请您通过<a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a>向我们pull request。</div>
+
+<p>{{Compat("javascript.builtins.URIError")}}</p>
+</div>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li>{{jsxref("Error")}}</li>
+ <li>{{jsxref("URIError.prototype")}}</li>
+ <li>{{jsxref("Global_Objects/decodeURI", "decodeURI()")}}</li>
+ <li>{{jsxref("Global_Objects/decodeURIComponent", "decodeURIComponent()")}}</li>
+ <li>{{jsxref("Global_Objects/encodeURI", "encodeURI()")}}</li>
+ <li>{{jsxref("Global_Objects/encodeURIComponent", "encodeURIComponent()")}}</li>
+</ul>
diff --git a/files/zh-cn/web/javascript/reference/global_objects/urierror/prototype/index.html b/files/zh-cn/web/javascript/reference/global_objects/urierror/prototype/index.html
new file mode 100644
index 0000000000..f011159690
--- /dev/null
+++ b/files/zh-cn/web/javascript/reference/global_objects/urierror/prototype/index.html
@@ -0,0 +1,82 @@
+---
+title: URIError.prototype
+slug: Web/JavaScript/Reference/Global_Objects/URIError/prototype
+translation_of: Web/JavaScript/Reference/Global_Objects/URIError
+---
+<div>{{JSRef}}</div>
+
+<div><code><strong>URIError.prototype</strong></code> 属性表示 {{jsxref("URIError")}} 构造器的原型。</div>
+
+<h2 id="描述">描述</h2>
+
+<p>所有的 {{jsxref("URIError")}} 实例都继承自 <code>URIError.prototype</code>。 可以通过原型(prototype) 给所有的实例添加属性或者方法。</p>
+
+<h2 id="属性">属性</h2>
+
+<dl>
+ <dt><code>URIError.prototype.constructor</code></dt>
+ <dd>声明创建实例原型 (prototype) 的方法。</dd>
+ <dt>{{jsxref("Error.prototype.message", "URIError.prototype.message")}}</dt>
+ <dd>错误信息。虽然 ECMA-262 规范指出 {{jsxref("URIError")}} 应该提供其自己专属的 <code><strong>message</strong></code><strong> </strong>属性,但是在 <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey">SpiderMonkey</a> 中,该属性继承自 {{jsxref("Error.prototype.message")}}</dd>
+ <dt>{{jsxref("Error.prototype.name", "URIError.prototype.name")}}</dt>
+ <dd>错误名称。继承自 {{jsxref("Error")}}。</dd>
+ <dt>{{jsxref("Error.prototype.fileName", "URIError.prototype.fileName")}}</dt>
+ <dd>产生该错误的代码所在文件的路径。 继承自 {{jsxref("Error")}}。</dd>
+ <dt>{{jsxref("Error.prototype.lineNumber", "URIError.prototype.lineNumber")}}</dt>
+ <dd>产生该错误的代码所在行的行号。继承自 {{jsxref("Error")}}。</dd>
+ <dt>{{jsxref("Error.prototype.columnNumber", "URIError.prototype.columnNumber")}}</dt>
+ <dd>产生该错误的代码所在列的列号。 继承自 {{jsxref("Error")}}。</dd>
+ <dt>{{jsxref("Error.prototype.stack", "URIError.prototype.stack")}}</dt>
+ <dd>堆栈记录。继承自 {{jsxref("Error")}}。</dd>
+</dl>
+
+<h2 id="方法">方法</h2>
+
+<p>虽然 {{jsxref("URIError")}} 的原型对象自身不包含任何方法,但是 {{jsxref("URIError")}} 的实例通过原型链(prototype chain)继承了一些方法。</p>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES3', '#sec-15.11.7.6', 'NativeError.prototype')}}</td>
+ <td>{{Spec2('ES3')}}</td>
+ <td> 初始定义</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.11.7.6', 'NativeError.prototype')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td> 定义为 <code><em>NativeError</em>.prototype</code>.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-nativeerror.prototype', 'NativeError.prototype')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td><font face="Open Sans, arial, x-locale-body, sans-serif"><span style="background-color: rgba(212, 221, 228, 0.15);"> 定义为</span></font><code><em>NativeError</em>.prototype</code>.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ESDraft', '#sec-nativeerror.prototype', 'NativeError.prototype')}}</td>
+ <td>{{Spec2('ESDraft')}}</td>
+ <td><font face="Open Sans, arial, x-locale-body, sans-serif"><span style="background-color: rgba(212, 221, 228, 0.25);"> 定义为</span></font><code><em>NativeError</em>.prototype</code>.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<div>
+
+
+<p>{{Compat("javascript.builtins.URIError")}}</p>
+</div>
+
+<h2 id="相关链接">相关链接</h2>
+
+<ul>
+ <li>{{jsxref("Error.prototype")}}</li>
+ <li>{{jsxref("Function.prototype")}}</li>
+</ul>