W3C home > Mailing lists > Public > public-webrtc@w3.org > December 2012

Move to de-facto error reporting

From: Travis Leithead <travis.leithead@microsoft.com>
Date: Thu, 20 Dec 2012 21:05:12 +0000
To: "public-media-capture@w3.org" <public-media-capture@w3.org>, "public-webrtc@w3.org" <public-webrtc@w3.org>
CC: "Jim Barnett (Jim.Barnett@genesyslab.com)" <Jim.Barnett@genesyslab.com>, "Adam Bergkvist (adam.bergkvist@ericsson.com)" <adam.bergkvist@ericsson.com>
Message-ID: <9768D477C67135458BF978A45BCF9B3853AF967D@TK5EX14MBXW604.wingroup.windeploy.ntdev.microsoft.com>
[Cross-posting for visibility] 

I'd like to suggest that we refactor our error handling behavior among all three WebRTC primary specs: WebRTC, Media Capture and Streams, and the Recording API. I'd like to move to the error model in use in DOM4/File API/IndexedDb and HTML5's Media Elements.

I pointed out in another thread (http://lists.w3.org/Archives/Public/public-media-capture/2012Dec/0163.html) that the WebRTC/Media Capture/Recording API specs are using an error-notification model that is not based on the model being used by other specs in the WebApps and HTML working group-namely we're basing our model off of the Geolocation spec's pattern, rather than that of the DOM4/File API/IndexedDb/HTML5 pattern.

The new pattern has only been around for a little over a year, so I don't think we can be blamed for not noticing/applying it earlier.

To summarize the differences in the patterns:
* The Geolocation pattern is to have a callback/event which is provided with an Error object which has a field which reports the name of the error (the error name and the exception names are usually the same). 
* The new pattern is to use a DOMError-based "error" attribute on the target object and use a normal vanilla "error" event to raise awareness that this state-attribute has been set.

Here's how the Geolocation pattern plays out in the WebRTC, Media Capture and Streams, and Recording API proposals:

An example from WebRTC's doc: RTCPeerConnection.createOffer says:
void createOffer(RTCSessionDescriptionCallback successCallback,
                 RTCPeerConnectionErrorCallback failureCallback, ...)

Where RTCPeerConnectionErrorCallback will get an RTCError, and the RTCError has a "name" and a "message"

This pattern is repeated elsewhere in getUserMedia: NavigatorUserMediaErrorCallback has a NavigatorUserMediaError with a "code".
and now in the Recording Proposal [1]: onrecordingerror gets a RecordingError object which has a "name" and a "message"

As you can see, this pattern needlessly complicates the web platform by having a bunch of objects that basically provide the exact same functionality.

In the WebApps and HTML working groups, they have also seen this proliferation, and decided to unify under a new pattern for providing asynchronous error notifications. In the new pattern, there is an error state which is maintained by an object, and an event that fires to inform the application to check the object's error state.

DOMError is the object that consolidates the functionality of RTCError, NavigatorUserMediaError, and RecordingError. It also consolidated similiarly proposed error objects in the File API, Indexed Db specs. The DOMError object is defined in DOM4 [2].

Here's how it looks in FileReader [3]:

interface FileReader {
   readonly attribute DOMError error;
            attribute Function? onerror;
   ...
}

Here it is for Indexed Db transaction request objects [4]:

interface IDBRequest {
   readonly attribute DOMError error;
            attribute Function? onerror;
   ...
}

Here's how it's used in HTML5 [5] (which uses codes, unfortunately, so it's based on the model before DOMError came around, and has now been widely implemented so it can't be changed):
Interface HTMLMediaElement {
   readonly attribute MediaError? error;
   ...
}
And an onerror handler defined in the super-interface HTMLElement.

I'd like to propose that we re-use this concept for our specs. The specific changes would apply to:

WebRTC spec:
* RTCPeerConnection interface would get a DOMError error attribute, and an onerror EventHandler. The following APIs would need to be adjusted/simplified to remove the failureCallback parameter:
  - createOffer
  - createAnswer
  - setLocalDescription
  - setRemoteDescription
  - getStats

Media Capture and Streams spec:
* MediaStream interface would get a DOMError error attribute, and an onerror EventHandler. The Following APIs would be adjusted to remove the errorCallback:
  - getUserMedia

Recording API spec:
* MediaRecorder interface would get a DOMError error attribute. This interface already has an onrecordingerror handler, and it would be simplified to not carry the error state and behave like other normal event objects.


[1] http://dvcs.w3.org/hg/dap/raw-file/tip/media-stream-capture/RecordingProposal.html
[2] http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-domerror
[3] http://dev.w3.org/2006/webapi/FileAPI/#dfn-error-codes
[4] http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#request-api 
[5] http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#mediaerror
Received on Thursday, 20 December 2012 21:06:08 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 20 December 2012 21:06:09 GMT