Exception handling (throwing and catching) is one of fundamental things of ECMAScript bindings in Web IDL. ExceptionState is designed to be a part of bindings interface like ScriptState is. A typical use case is:
void webExposedApi(ScriptState*, ExceptionState&);
So, let's move ExceptionState into platform/. This allows code in platform/ report an error by throwing an exception.
DOMException is defined in Web IDL, however, it's pretty exceptional (maybe only one instance of actual IDL interface definition in Web IDL). DOMException is implemented with ScriptWrappable and support of generated bindings code, so we don't move DOMException and leave it in core/.
Having said that, an ability to throw an arbitrary exception is pretty important and convenient for ExceptionState, so we allow ExceptionState to throw a DOMException by dependency injection.
Also note that Web IDL defines "perform a security check" that is injected from HTML, and HTML throws a SecurityError that is an instance of DOMException. So, the definition of DOMException code will be moved to platform/ so that ExceptionState can handle SecurityError specifically.
The final state will be:
in platform/
- ExceptionCode
- V8ErrorType (will be renamed to ESErrorType)
- DOMException code
- ExceptionState
in core/
- DOMException (ScriptWrappable + generated bindings)
Comment 1 by bugdroid1@chromium.org
, Jun 5 2018