Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #33249
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Object.defineProperties |
| Date | 2017-05-07 17:11 +0200 |
| Organization | PointedEars Software (PES) |
| Message-ID | <1783967.oMNUckLgyt@PointedEars.de> (permalink) |
| References | (6 earlier) <oekitc$2tgv$1@csiph.com> <oelc5o$4iv$1@news.albasani.net> <oeldrk$j52$1@csiph.com> <38321860.ZmDeoRnzTM@PointedEars.de> <oemj5r$1frd$1@csiph.com> |
Cezary Tomczyk wrote:
> On 07/05/2017 02:37, Thomas 'PointedEars' Lahn wrote:
>> Cezary Tomczyk wrote:
>>> function isTypeOf(obj, typeToCheck) {
>>> var type;
>>>
>>> if (arguments.length < 2) {
>>> throw new Error('[isTypeOf] requires two arguments');
>>> }
>>
>> You should throw a TypeError or a custom-typed exception (I throw
>> object.js:jsx.InvalidArgumentError for such).
>
> Nice tip. I will use:
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError
>
> However, optional argument 'lineNumber' there is a bit weird to me as I
> don't know where the specified fragment of code will be in a production
> version (after minification) and therefore I can't pass there a line
> number.
It is optional and proprietary anyway.
But, if available, you can obtain the URI and line number from the “stack”
property and set them later. (This is where custom-typed exceptions come
in.)
>> The message is confusing (“Is ‘isTypeOf’ the element of a one-element
>> array?”)
>
> The purpose of that message is to tell you where the message happened,
> here the '[isTypeOf]' refers to function name, and what happened, here
> is a message that 'requires two arguments'.
I *know* what it is *supposed* to tell. It is nevertheless confusing to the
person reading it. The message should not require such an explanation.
It should also say more than “requires two arguments” because the next
question of the developer would be “What arguments does it require, then?”.
See also jsx.InvalidArgumentError; currently
<https://github.com/PointedEars/JSX/blob/master/object.js#L3924-L3947>
Usage example:
<https://github.com/PointedEars/JSX/blob/master/object.js#L2669-L2671>
--
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Object.defineProperties Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-05-03 08:36 +0200
Re: Object.defineProperties Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-05-03 10:14 +0200
Re: Object.defineProperties Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-05-03 10:59 +0200
Re: Object.defineProperties Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-05-03 12:36 +0200
Re: Object.defineProperties Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-05-03 18:47 +0200
Re: Object.defineProperties Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-05 18:18 +0200
Re: Object.defineProperties Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-05 18:14 +0200
Re: Object.defineProperties Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-05-05 19:37 +0200
Re: Object.defineProperties Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-05 20:11 +0200
Re: Object.defineProperties Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-05-06 15:26 +0200
Re: Object.defineProperties Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-06 16:43 +0200
Re: Object.defineProperties Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-05-06 20:23 +0200
Re: Object.defineProperties Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-06 22:21 +0200
Re: Object.defineProperties Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-05-06 23:19 +0200
Re: Object.defineProperties Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-07 02:40 +0200
Re: Object.defineProperties Stefan Weiss <krewecherl@gmail.com> - 2017-05-06 22:37 +0200
Re: Object.defineProperties Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-05-06 23:05 +0200
Re: Object.defineProperties Stefan Weiss <krewecherl@gmail.com> - 2017-05-07 00:29 +0200
Re: Object.defineProperties Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-05-07 10:06 +0200
Re: Object.defineProperties Stefan Weiss <krewecherl@gmail.com> - 2017-05-08 00:50 +0200
Re: Object.defineProperties Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-05-08 13:17 +0200
Re: Object.defineProperties Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-07 02:37 +0200
Re: Object.defineProperties Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-05-07 09:42 +0200
Re: Object.defineProperties Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-07 17:11 +0200
Re: Object.defineProperties Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-05-07 20:08 +0200
Re: Object.defineProperties Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-05 20:59 +0200
Re: Object.defineProperties John G Harris <niam@jghnorth.org.uk.invalid> - 2017-05-06 10:35 +0100
Re: Object.defineProperties Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2017-05-05 08:32 +0200
Re: Object.defineProperties Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-05 18:24 +0200
csiph-web