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

[webrtc-pc] Misuse of SyntaxError

From: Rick Waldron via GitHub <sysbot+gh@w3.org>
Date: Wed, 07 Jun 2017 18:17:04 +0000
To: public-webrtc-logs@w3.org
Message-ID: <issues.opened-234298226-1496859423-sysbot+gh@w3.org>
rwaldron has just created a new issue for https://github.com/w3c/webrtc-pc:

== Misuse of SyntaxError ==
In step 8 of https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-createdatachannel: 

> 8. If both the maxPacketLifeTime and maxRetransmits attributes are set (not null), throw a SyntaxError.

This error must not be a SyntaxError, [which defined as](https://tc39.github.io/ecma262/#sec-native-error-types-used-in-this-standard-syntaxerror):

> Indicates that a parsing error has occurred.

The correct error to use is TypeError. Given the same case, applied to descriptor properties: 

Object.defineProperty({}, "foo", {
  get() {
    return 1;
  writable: false

Will have such results as: 

- Firefox
  TypeError: property descriptors must not specify a value or be writable when a getter 
  or setter has been specified
- Chrome
  Uncaught TypeError: Invalid property descriptor. Cannot both specify accessors and a 
  value or writable attribute, #<Object>
- Safari
  TypeError: Invalid property.  'writable' present on property with getter or setter.

I recommend throwing a TypeError with message "Invalid options, maxPacketLifeTime and maxRetransmits cannot both be null" (or something similar)

Please view or discuss this issue at https://github.com/w3c/webrtc-pc/issues/1355 using your GitHub account
Received on Wednesday, 7 June 2017 18:17:11 UTC

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