-
Notifications
You must be signed in to change notification settings - Fork 4
/
585.txt
155 lines (113 loc) · 7.43 KB
/
585.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
[4] [DFN[[RUBYB[例外]@en[exception]]]]は、[[エラー]]を表す[[オブジェクト]]です。
* 仕様書
[REFS[
- [2] '''[CITE[Web IDL (Second Edition)]] ([TIME[2015-05-27 01:29:33 +09:00]] 版) <http://heycam.github.io/webidl/#dfn-exception>'''
- [12] [CITE[Web IDL (Second Edition)]] ([TIME[2015-05-27 01:29:33 +09:00]] 版) <http://heycam.github.io/webidl/#es-exceptions>
]REFS]
* 意味
[3] [[例外]]は、[[エラー]]を表現する[[オブジェクト]]の[[型]]で、
[[投げる]]ことができたり、[[実装]]が第一級クラス値として暑かったりするものです [SRC[>>2]]。
* 例外
[5] [[例外]]には次のものがあります。
[FIG(short list)[
- [[単純例外]]
- [CODE(IDL)@en[[[DOMException]]]]
]FIG]
[6] 以前の [[Web IDL]] (や [[OMG IDL]]) では [CODE(IDL)@en[[[exception]]]]
構文により[[例外]]を定義することができました。 [[W3C DOM]] 時代には
[CODE(IDL)@en[[[LSException]]]] などいくつかの[[例外]]インターフェイスが定義されていました。
しかし現在は廃止され、 [[Web IDL]] 仕様のみで[[例外]]が規定されています。
* 状態
[7] [[例外]]には次の状態があります。
[FIG(list members)[
:[[エラー名]]:[[例外]]の種類を表す文字列です。
:[[メッセージ (例外)]]:エラー情報を表す文字列です。
]FIG]
[8] 他にもエラーの種類に依存した状態を持ちます。
* 演算
[9] [[例外]]は、[[エラー名]]を指定して[DFN[[RUBYB[作成]@en[create]]]]できます [SRC[>>2]]。
その動作は[[言語束縛]]により決まります [SRC[>>2]]。
[13] [[JavaScript]] では、次のようにしなければ[['''なりません''']] [SRC[>>12]]。
[FIG(steps)[
= [[利用者エージェント]]定義のメッセージが指定されていれば、 [CODE(JS)@en[[[String]]]]
[[JavaScript値に変換]]します。定義されていなければ、 [CODE(JS)@en[[[undefined]]]]
とします。
= [[エラー名]]を、 [CODE(JS)@en[[[String]]]] [[JavaScript値に変換]]します。
= 作成するのが[[単純例外]]なら、
== [[現在大域環境]]の[[エラー名]]に対応する[[コンストラクター]]を[[関数]]として呼び出します。
[[引数]]は、[[利用者エージェント]]定義のメッセージとします。
== その結果を返します。
= 作成するのが [CODE(DOMi)@en[[[DOMException]]]] なら、
== [[現在大域環境]]の [[DOMExceptionコンストラクターオブジェクト]]を[[関数]]として呼び出します。
[[引数]]は、 [CODE(JS)@en[[[undefined]]]] と[[エラー名]]とします。
== その結果を返します。
]FIG]
;; [11] [[DOMException]] なら[[利用者エージェント]]定義の[[メッセージ (例外)]]は使わないことになります。
しかし実際には [CODE(JS)@en[[[DOMException]]]] [[オブジェクト]]は
[CODE(DOMa)@en[[[message]]]] [[IDL属性]]が[[利用者エージェント]]依存の値を持つことがあるようです。
[10] [[例外]]は、[[投げる]]ことができます [SRC[>>2]]。
* 歴史
[1] [CITE@en[Re: Exceptions in event listeners triggered by dispatchEvent().]]
( ([[Anne van Kesteren]] 著, [TIME[2013-06-03 18:33:37 +09:00]] 版))
<http://lists.w3.org/Archives/Public/www-dom/2013AprJun/0161.html>
** 例外インターフェイスオブジェクト
[REFS[
- [14] [CITE[Web IDL (Second Edition)]] ([TIME[2014-02-10 21:45:38 +09:00]] 版) <http://heycam.github.io/webidl/#es-exceptions>
]REFS]
[15] 次の条件を満たすものは、[[大域オブジェクト]]上に対応する[[特性]]が作られます [SRC[>>14]]。
[REFS[
- [16] [[例外]]である
- [17] [CODE(IDL)@en[[[NoInterfaceObject]]]] [[拡張属性]]を持たない
]REFS]
;; [18] [[インターフェイスオブジェクト]]とは違って [CODE(IDL)@en[[[Exposed]]]]
[[拡張属性]]が存在しません。
[19] この[[特性]]は、[[例外]]の[[識別子]]が[[名前]]であり、
[[例外インターフェイスオブジェクト]]と呼ばれる[[オブジェクト]]が値です [SRC[>>14]]。
;; [20] [[インターフェイス]]に対する[[インターフェイスオブジェクト]]と実質的に同じものです。
[21] [[例外インターフェイスオブジェクト]]は、 [CODE(IDL)@en[[[exception]]]]
の[[廃止]]により、削除されました。 [[[CODE(DOMi)@en[DOMException]]構築子オブジェクト]]のみが残っています。
[22] [CITE@en[Remove remaining references to exception constructors. · heycam/webidl@b14f85b]]
([TIME[2016-02-16 11:03:36 +09:00]] 版)
<https://github.com/heycam/webidl/commit/b14f85b3522a625e419b5d61ef08b0bd67735ef6>
[23] [CITE@en[Remove remaining reference to exception field getters. · heycam/webidl@f0d5c92]]
([TIME[2016-02-16 11:03:49 +09:00]] 版)
<https://github.com/heycam/webidl/commit/f0d5c929d027263ae4027af931626fbcc109b662>
[24] [CITE@en[17713 – Exceptions thrown from event handlers should not be propagated]]
([TIME[2016-03-15 12:04:25 +09:00]] 版)
<https://www.w3.org/Bugs/Public/show_bug.cgi?id=17713>
[25] [CITE@en[Editorial: align exception language with IDL · whatwg/dom@e4b93c8]]
([TIME[2016-04-20 15:26:03 +09:00]] 版)
<https://github.com/whatwg/dom/commit/e4b93c8c025a826bd163bf9148d729a2d429e4d2>
[26] [CITE@en[Use WebIDL-suggested text for exception throwing/creation]]
( ([[inexorabletash]]著, [TIME[2016-06-01 07:58:54 +09:00]]))
<https://github.com/w3c/IndexedDB/commit/25500769ec45e8ca6c91d80accf7112e9f74b2ae>
[27] [CITE@en[An exception is not always an object (e.g., throw 7)]]
([[annevk]]著, [TIME[2016-08-30 04:09:45 +09:00]])
<https://github.com/whatwg/html/commit/6f32dc2cdbde1991dfa8ba2bf79a2eebe18324cd>
[28] [CITE@en[Switching to new, consistent terminology when talking about exceptions.]]
([[taylor-b]]著, [TIME[2017-03-07 08:53:24 +09:00]])
<https://github.com/w3c/webrtc-pc/commit/f461c991a1b8ebaa9a499f2ba9431a26bcb01987>
[29] [CITE@en[Editorial: remove "rethrow any exception"]]
([[annevk]]著, [TIME[2017-03-24 20:27:29 +09:00]])
<https://github.com/whatwg/dom/commit/d298c5b7c690fb6a12bb487fd43549c5b46520bc>
[30] [CITE@en[Clarify exception catching language]]
([[domenic]]著, [TIME[2017-07-18 04:25:03 +09:00]])
<https://github.com/whatwg/html/commit/5a2087f95d9be0a3bea2ac2c6a35c70c63782f9a>
[31] [CITE@en[Update and link ES exception handling (#417)]]
([[TimothyGu]]著, [TIME[2017-08-19 18:09:02 +09:00]])
<https://github.com/heycam/webidl/commit/cfe97e12129d249879aabba406a32969f2c8b0b4>
[32] [CITE@en[Update and link ES exception handling by TimothyGu · Pull Request #417 · heycam/webidl]]
([TIME[2017-08-20 11:14:29 +09:00]])
<https://github.com/heycam/webidl/pull/417>
[33] [CITE@en[How does CEReactions interact with thrown exceptions? · Issue #3217 · whatwg/html]]
([TIME[2017-11-18 15:06:22 +09:00]])
<https://github.com/whatwg/html/issues/3217>
[34] [CITE@en[Remove the Error IDL type]]
([[Ms2ger]]著, [TIME[2019-05-17 22:52:31 +09:00]])
<https://github.com/heycam/webidl/commit/ad03037c82890e7ac496b96922552f465c45c0a7>
[35] [CITE@en[Remove the Error IDL type by Ms2ger · Pull Request #728 · heycam/webidl]]
([TIME[2020-01-12 14:12:41 +09:00]])
<https://github.com/heycam/webidl/pull/728>
[36] [CITE@en[Remove the 'exception types' definition]]
([[Ms2ger]]著, [TIME[2019-05-17 23:21:01 +09:00]])
<https://github.com/heycam/webidl/commit/faaee577b0c0c03338b139754835ac999de507be>