Exception

例外 (JavaScript)

[4] 例外 (exception) は、エラーを表すオブジェクトです。

仕様書

意味

[3] 例外は、エラーを表現するオブジェクトで、 投げることができたり、実装が第一級クラス値として暑かったりするものです >>2

例外

[5] 例外には次のものがあります。

[6] 以前の Web IDL (や OMG IDL) では exception 構文により例外を定義することができました。 W3C DOM 時代には LSException などいくつかの例外インターフェイスが定義されていました。 しかし現在は廃止され、 Web IDL 仕様のみで例外が規定されています。

状態

[7] 例外には次の状態があります。

エラー名
例外の種類を表す文字列です。
メッセージ (例外)
エラー情報を表す文字列です。

[8] 他にもエラーの種類に依存した状態を持ちます。

演算

[9] 例外は、エラー名を指定して作成 (create) できます >>2。 その動作は言語束縛により決まります >>2

[13] JavaScript では、次のようにしなければなりません >>12

  1. 利用者エージェント定義のメッセージが指定されていれば、 String JavaScript値に変換します。定義されていなければ、 undefined とします。
  2. エラー名を、 String JavaScript値に変換します。
  3. 作成するのが単純例外なら、
    1. 現在大域環境エラー名に対応するコンストラクター関数として呼び出します。 引数は、利用者エージェント定義のメッセージとします。
    2. その結果を返します。
  4. 作成するのが DOMException なら、
    1. 現在大域環境DOMExceptionコンストラクターオブジェクト関数として呼び出します。 引数は、 undefinedエラー名とします。
    2. その結果を返します。

[11] DOMException なら利用者エージェント定義のメッセージ (例外)は使わないことになります。 しかし実際には DOMException オブジェクトmessage IDL属性利用者エージェント依存の値を持つことがあるようです。

[10] 例外は、投げることができます >>2

歴史

[1] Re: Exceptions in event listeners triggered by dispatchEvent(). ( (Anne van Kesteren 著, 版)) http://lists.w3.org/Archives/Public/www-dom/2013AprJun/0161.html

例外インターフェイスオブジェクト

[15] 次の条件を満たすものは、大域オブジェクト上に対応する特性が作られます >>14

[19] この特性は、例外識別子名前であり、 例外インターフェイスオブジェクトと呼ばれるオブジェクトが値です >>14

[20] インターフェイスに対するインターフェイスオブジェクトと実質的に同じものです。

[21] 例外インターフェイスオブジェクトは、 exception廃止により、削除されました。 DOMException構築子オブジェクトのみが残っています。

[22] Remove remaining references to exception constructors. · heycam/webidl@b14f85b ( 版) https://github.com/heycam/webidl/commit/b14f85b3522a625e419b5d61ef08b0bd67735ef6

[23] Remove remaining reference to exception field getters. · heycam/webidl@f0d5c92 ( 版) https://github.com/heycam/webidl/commit/f0d5c929d027263ae4027af931626fbcc109b662

[24] 17713 – Exceptions thrown from event handlers should not be propagated ( 版) https://www.w3.org/Bugs/Public/show_bug.cgi?id=17713

[25] Editorial: align exception language with IDL · whatwg/dom@e4b93c8 ( 版) https://github.com/whatwg/dom/commit/e4b93c8c025a826bd163bf9148d729a2d429e4d2

[26] Use WebIDL-suggested text for exception throwing/creation ( (inexorabletash著, )) https://github.com/w3c/IndexedDB/commit/25500769ec45e8ca6c91d80accf7112e9f74b2ae

[27] An exception is not always an object (e.g., throw 7) (annevk著, ) https://github.com/whatwg/html/commit/6f32dc2cdbde1991dfa8ba2bf79a2eebe18324cd

[28] Switching to new, consistent terminology when talking about exceptions. (taylor-b著, ) https://github.com/w3c/webrtc-pc/commit/f461c991a1b8ebaa9a499f2ba9431a26bcb01987

[29] Editorial: remove "rethrow any exception" (annevk著, ) https://github.com/whatwg/dom/commit/d298c5b7c690fb6a12bb487fd43549c5b46520bc

[30] Clarify exception catching language (domenic著, ) https://github.com/whatwg/html/commit/5a2087f95d9be0a3bea2ac2c6a35c70c63782f9a

[31] Update and link ES exception handling (#417) (TimothyGu著, ) https://github.com/heycam/webidl/commit/cfe97e12129d249879aabba406a32969f2c8b0b4

[32] Update and link ES exception handling by TimothyGu · Pull Request #417 · heycam/webidl () https://github.com/heycam/webidl/pull/417

[33] How does CEReactions interact with thrown exceptions? · Issue #3217 · whatwg/html () https://github.com/whatwg/html/issues/3217

[34] Remove the Error IDL type (Ms2ger著, ) https://github.com/heycam/webidl/commit/ad03037c82890e7ac496b96922552f465c45c0a7

[35] Remove the Error IDL type by Ms2ger · Pull Request #728 · heycam/webidl () https://github.com/heycam/webidl/pull/728

[36] Remove the 'exception types' definition (Ms2ger著, ) https://github.com/heycam/webidl/commit/faaee577b0c0c03338b139754835ac999de507be

[37] Remove the Error IDL type by Ms2ger · Pull Request #728 · heycam/webidl () https://github.com/heycam/webidl/pull/728