Skip to content

Commit 5e1d7e8

Browse files
committed
Upgrade QuotaExceededError to a DOMException derived interface
Closes #1463.
1 parent 90b5184 commit 5e1d7e8

File tree

1 file changed

+92
-52
lines changed

1 file changed

+92
-52
lines changed

index.bs

+92-52
Original file line numberDiff line numberDiff line change
@@ -5158,11 +5158,6 @@ over just using {{SyntaxError!!exception}} to refer to the {{DOMException}}. [[D
51585158
<td><strong>Deprecated.</strong></td>
51595159
<td><dfn id="dom-domexception-url_mismatch_err" for="DOMException" const export><code>URL_MISMATCH_ERR</code></dfn>&nbsp;(21)</td>
51605160
</tr>
5161-
<tr>
5162-
<td>"<dfn id="quotaexceedederror" exception export><code>QuotaExceededError</code></dfn>"</td>
5163-
<td>The quota has been exceeded.</td>
5164-
<td><dfn id="dom-domexception-quota_exceeded_err" for="DOMException" const export><code>QUOTA_EXCEEDED_ERR</code></dfn>&nbsp;(22)</td>
5165-
</tr>
51665161
<tr>
51675162
<td>"<dfn id="timeouterror" exception export><code>TimeoutError</code></dfn>"</td>
51685163
<td>The operation timed out.</td>
@@ -5260,70 +5255,114 @@ certain rules, in order to have a predictable shape for developers. Specifically
52605255
<p class=note>These requirements mean that the inherited {{DOMException/code}} property of these
52615256
interfaces will always return 0.
52625257

5263-
<div class=example id=example-domexception-derived-interface>
5264-
The definition for a {{DOMException}} derived interface which carries along an additional
5265-
"protocol error code", which is derived from what the server sent over some some hypothetical
5266-
network protocol "protocol X", could look something like this:
5258+
To [=exception/create=] or [=exception/throw=] a {{DOMException}} derived interface, supply its
5259+
[=interface=] [=identifier=] as well as the additional information needed to construct it.
52675260

5268-
<pre highlight=webidl>
5269-
[Exposed=Window, Serializable]
5270-
interface ProtocolXError : DOMException {
5271-
constructor(optional DOMString message = "", ProtocolXErrorOptions options);
5261+
<div class=example id=example-domexception-derived-throwing>
5262+
<p>To throw an instance of {{QuotaExceededError}}:
52725263

5273-
readonly attribute unsigned long long errorCode;
5274-
};
5264+
<blockquote>
5265+
<p>[=exception/Throw=] a {{QuotaExceededError}} whose [=QuotaExceededError/quota=] is 42 and
5266+
[=QuotaExceededError/requested=] is 50.
5267+
</blockquote>
5268+
</div>
52755269

5276-
dictionary ProtocolXErrorOptions {
5277-
required [EnforceRange] unsigned long long errorCode;
5278-
};
5279-
</pre>
5270+
<h4 id="idl-DOMException-derived-predefineds" oldids="example-domexception-derived-interface">Predefined {{DOMException}} derived interfaces</h4>
52805271

5281-
Every <code>ProtocolXError</code> instance has an <dfn for="ProtocolXError">error code</dfn>,
5282-
a number.
5272+
This standard so far defines one predefined {{DOMException}} derived interface:
52835273

5284-
<div algorithm="ProtocolXError constructor">
5285-
The <b><code>new ProtocolXError(|message|, |options|)</code></b> constructor steps are:
5274+
<pre class=idl>
5275+
[Exposed=*, Serializable]
5276+
interface QuotaExceededError : DOMException {
5277+
constructor(optional DOMString message = "", optional QuotaExceededErrorOptions options = {});
52865278

5287-
1. Set [=this=]'s [=DOMException/name=] to "<code>ProtocolXError</code>".
5288-
1. Set [=this=]'s [=DOMException/message=] to |message|.
5289-
1. Set [=this=]'s [=ProtocolXError/error code=] to |options|["<code>errorCode</code>"].
5290-
</div>
5279+
readonly attribute double? quota;
5280+
readonly attribute double? requested;
5281+
};
52915282

5292-
<div algorithm="ProtocolXError errorCode">
5293-
The <b><code>errorCode</code></b> getter steps are to return [=this=]'s
5294-
[=ProtocolXError/error code=].
5295-
</div>
5283+
dictionary QuotaExceededErrorOptions {
5284+
double quota;
5285+
double requested;
5286+
};
5287+
</pre>
52965288

5297-
<code>ProtocolXError</code> objects are [=serializable objects=].
5289+
The {{QuotaExceededError}} exception can be thrown when a quota is exceeded. It has two properties
5290+
that are optionally present, to give more information to the web developer about their request
5291+
compared to the quota value.
52985292

5299-
<div algorithm="ProtocolXError serialization steps">
5300-
Their [=serialization steps=], given |value| and |serialized|, are:
5293+
<p class="note">Previous versions of this standard defined "<code>QuotaExceededError</code>" as one
5294+
of the <a href="#idl-DOMException-error-names">base <code>DOMException</code> error names</a>. It
5295+
has been upgraded to a full interface to support including such information.</p>
53015296

5302-
1. Run the {{DOMException}} [=serialization steps=] given |value| and |serialized|.
5303-
1. Set |serialized|.\[[ErrorCode]] to |value|'s [=ProtocolXError/error code=].
5304-
</div>
5297+
Every {{QuotaExceededError}} instance has a <dfn for="QuotaExceededError">requested</dfn> and a
5298+
<dfn for="QuotaExceededError">quota</dfn>, both numbers or null. They are both initially null.
5299+
5300+
<div algorithm>
5301+
The <dfn constructor for="QuotaExceededError" lt="QuotaExceededError(message, options)">new QuotaExceededError(|message|, |options|)</dfn>
5302+
constructor steps are:
53055303

5306-
<div algorithm="ProtocolXError deserialization steps">
5307-
Their [=deserialization steps=], given |serialized| and |value|, are:
5304+
1. Set [=this=]'s [=DOMException/name=] to "<code>QuotaExceededError</code>".
53085305

5309-
1. Run the {{DOMException}} [=deserialization steps=] given |serialized| and |value|.
5310-
1. Set |value|'s [=ProtocolXError/error code=] to |serialized|.\[[ErrorCode]].
5311-
</div>
5306+
1. Set [=this=]'s [=DOMException/message=] to |message|.
5307+
5308+
1. If |options|["{{QuotaExceededErrorOptions/quota}}"] is present, then:
5309+
5310+
1. If |options|["{{QuotaExceededErrorOptions/quota}}"] is less than 0, then throw a
5311+
{{RangeError}}.
5312+
5313+
1. Set [=this=]'s [=QuotaExceededError/quota=] to
5314+
|options|["{{QuotaExceededErrorOptions/quota}}"].
5315+
5316+
1. If |options|["{{QuotaExceededErrorOptions/requested}}"] is present, then:
5317+
5318+
1. If |options|["{{QuotaExceededErrorOptions/requested}}"] is less than 0, then throw a
5319+
{{RangeError}}.
5320+
5321+
1. Set [=this=]'s [=QuotaExceededError/requested=] to
5322+
|options|["{{QuotaExceededErrorOptions/requested}}"].
5323+
5324+
1. If [=this=]'s [=QuotaExceededError/quota=] is not null, [=this=]'s [=QuotaExceededError/requested=] is not null,
5325+
and [=this=]'s [=QuotaExceededError/requested=] is less than [=this=]'s [=QuotaExceededError/quota=], then
5326+
throw a {{RangeError}}.
53125327
</div>
53135328

5314-
To [=exception/create=] or [=exception/throw=] a {{DOMException}} derived interface, supply its
5315-
[=interface=] [=identifier=] as well as the additional information needed to construct it.
5329+
The <dfn attribute for="QuotaExceededError">quota</dfn> getter steps are to return [=this=]'s
5330+
[=QuotaExceededError/quota=].
53165331

5317-
<div class=example id=example-domexception-derived-throwing>
5318-
<p>To throw an instance of the <code>ProtocolXError</code> exemplified
5319-
<a href=#example-domexception-derived-interface>above</a>:
5332+
The <dfn attribute for="QuotaExceededError">requested</dfn> getter steps are to return [=this=]'s
5333+
[=QuotaExceededError/requested=].
53205334

5321-
<blockquote>
5322-
<p>[=exception/Throw=] a <code>ProtocolXError</code> whose [=ProtocolXError/error code=]
5323-
is 42.
5324-
</blockquote>
5335+
<hr>
5336+
5337+
{{QuotaExceededError}} objects are [=serializable objects=].
5338+
5339+
<div algorithm="QuotaExceededError serialization steps">
5340+
Their [=serialization steps=], given |value| and |serialized|, are:
5341+
5342+
1. Run the {{DOMException}} [=serialization steps=] given |value| and |serialized|.
5343+
5344+
1. Set |serialized|.\[[Quota]] to |value|'s [=QuotaExceededError/quota=].
5345+
5346+
1. Set |serialized|.\[[Requested]] to |value|'s [=QuotaExceededError/requested=].
53255347
</div>
53265348

5349+
<div algorithm="QuotaExceededError deserialization steps">
5350+
Their [=deserialization steps=], given |serialized| and |value|, are:
5351+
5352+
1. Run the {{DOMException}} [=deserialization steps=] given |serialized| and |value|.
5353+
5354+
1. Set |value|'s [=QuotaExceededError/quota=] to |serialized|.\[[Quota]].
5355+
5356+
1. Set |value|'s [=QuotaExceededError/requested=] to |serialized|.\[[Requested]].
5357+
</div>
5358+
5359+
<hr>
5360+
5361+
Specifications that [=exception/create=] or [=exception/throw=] a {{QuotaExceededError}} must not
5362+
provide a [=QuotaExceededError/requested=] and [=QuotaExceededError/quota=] that are both non-null
5363+
and where [=QuotaExceededError/requested=] is less than [=QuotaExceededError/quota=].
5364+
5365+
53275366
<h3 id="idl-enums">Enumerations</h3>
53285367

53295368
An <dfn id="dfn-enumeration" export>enumeration</dfn> is a definition (matching
@@ -6651,7 +6690,8 @@ There is no way to represent a constant observable array value in IDL.
66516690

66526691
1. If |employee| is not allowed to enter the building today, then throw a
66536692
"{{NotAllowedError}}" {{DOMException}}.
6654-
1. If |index| is greater than 200, then throw a "{{QuotaExceededError}}" {{DOMException}}.
6693+
1. If |index| is greater than or equal to 200, then throw a {{QuotaExceededError}} whose
6694+
[=QuotaExceededError/quota=] is 200 and [=QuotaExceededError/requested=] is |index|.
66556695
1. Put |employee| to work!
66566696

66576697
The [=observable array attribute/delete an indexed value=] algorithm for

0 commit comments

Comments
 (0)