Allen Wirfs-Brock (2014-01-30T16:44:31.000Z)
domenic at domenicdenicola.com (2014-01-30T17:30:36.998Z)
So far we've avoiding adding any new built-in exceptions. Perhaps, we could add another but I think it would take some time to build consensus around that. In practice new library functions in ES6 restrict themselves to using either TypeError or RangeError with TypeError being by far the most common. Range error is used when a parameter or other value is (likely) of the correct primitive type (number, string, etc.) but the specific value is not contextually valid. Pretty much everything else is treated as a TypeError. Note that in this context we interpret "Type" more like "kind" than corresponding the ECMAScript types. You can think about this usage of TypeError as "the wrong kind of thing was directly or indirectly passed to the function". If you invert things you can think of "invalid operation" as trying to apply a valid operation upon the "wrong kind of object" so TypeError is a plausible. In practice, where would throwing OperationError instead of TypeError actually make any difference. How would you handle one differently from the other?