Error objects: RangeError, TypeError, ValueError
Allen Wirfs-Brock
allen at wirfs-brock.com
Tue Nov 22 10:49:03 PST 2011
On Nov 22, 2011, at 10:14 AM, Brendan Eich wrote:
> On Nov 22, 2011, at 9:37 AM, Allen Wirfs-Brock wrote:
> ...
>
>> Unfortunately, as it now stands you have to use the implementation dependent message property value to actually identify specific exceptions.
>
> *Error.prototype.name is normatively specified for all the built-in Error constructors.
Yes, but name doesn't discriminate the actual cause of the exception. There is no normative way to distinguish a RangeError generated by 1.0.toPrecision(40) from a RangeError generated by (new Array(1.2))
>
>
>> I wonder if for new exception occurrences (in our specs.) we should specify unique implementation independent name property values. To do so, we would have to develop a meaningful fine-grained naming scheme.
>
> This would fit in just Error, as JJB just suggested.
The difference is that instanceof can be used to detect RageError, TypeError, etc. instances
Allen
More information about the es-discuss
mailing list