Path: csiph.com!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Object.defineProperties Date: Sun, 07 May 2017 17:11:04 +0200 Organization: PointedEars Software (PES) Lines: 54 Message-ID: <1783967.oMNUckLgyt@PointedEars.de> References: <1943190.NgBsaNRSFp@PointedEars.de> <1592229.TLkxdtWsSY@PointedEars.de> <38321860.ZmDeoRnzTM@PointedEars.de> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1494169864 11851 eJwFwQERACAIA8BKgAxcHE9Z/wj+Y5XX7SxUQlA7F0W3Ruj2+N6bNqaTRTvU07QXnscEFz4FrxBh (7 May 2017 15:11:04 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sun, 7 May 2017 15:11:04 +0000 (UTC) User-Agent: KNode/4.14.2 X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. 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 Usage example: -- PointedEars FAQ: | | Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.