W3C home > Mailing lists > Public > public-webrtc-logs@w3.org > July 2017

Re: [webrtc-pc] Section 12: Missing WebIDL in RTCError

From: jan-ivar via GitHub <sysbot+gh@w3.org>
Date: Wed, 05 Jul 2017 19:31:25 +0000
To: public-webrtc-logs@w3.org
Message-ID: <issue_comment.created-313203301-1499283083-sysbot+gh@w3.org>
@aboba Sorry for the late followup. I'll try to cover @soareschen's [questions](https://github.com/w3c/webrtc-pc/issues/1416#issue-237766720) here as well:

There can't be a WebIDL definition of RTCError interface, as defined, because WebIDL offers no way to extend errors, leaving us to define everything in prose. While I don't know of anyone saying so on record, this seems by design to discourage this very pattern of custom error properties, or at least we failed to convince enough people this pattern deserved to be easier. @domenic @bzbarsky.

RTCError is modeled on OverconstrainedError added in https://github.com/w3c/mediacapture-main/pull/194 for backstory.

> The enum RTCErrorDetailType is defined but not referenced in the RTCError constructor.

Without WebIDL we don't have the advantage of WebIDL bindings doing things like enum checking with `TypeError`. We'd have to do that in prose I suspect. You're right this appears to be missing. 

@aboba [Section 12.2.4.](http://w3c.github.io/webrtc-pc/#properties-of-rtcerror-instances) looks right to me. I think you're mixing `RTCError` and `RTCErrorEvent`.

If `RTCError` were only used in `RTCErrorEvent`, I'd recommend dropping it in favor of moving the properties to `RTCErrorEvent`. Solves WebIDL. Error objects in events aren't super-useful anyway, since (non-standard yet common) properties like `stack`, `fileName`, and `lineNumber` are wasted. The only advantage would be if we expect JS to [rethrow the error](https://jsfiddle.net/jib1/pkc16k9r/) within its own app a lot. E.g.:
```js
await Promise.Race([done, new Promise(() => pc.onerror = e => { throw e.error; })]);
```

Alas, `RTCError` appears to also be thrown from [various](http://w3c.github.io/webrtc-pc/#set-description) [methods](http://w3c.github.io/webrtc-pc/#sec.idp-error-handling).

If it were up to me, I'd at minimum move as many properties off the error and onto `RTCErrorEvent` as possible.

I'd probably also re-examine the overlap between the error event and the methods, and if the overlap isn't substantial, maybe look at defining `RTCErrorEvent` without the `error` member.

Or somewhere in the middle. Hope that helps.

-- 
GitHub Notification of comment by jan-ivar
Please view or discuss this issue at https://github.com/w3c/webrtc-pc/issues/1158#issuecomment-313203301 using your GitHub account
Received on Wednesday, 5 July 2017 19:31:31 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:21:40 UTC