Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EDEE910C4E for ; Tue, 5 Nov 2013 13:25:57 +0000 (UTC) Received: (qmail 85554 invoked by uid 500); 5 Nov 2013 13:22:49 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 85393 invoked by uid 500); 5 Nov 2013 13:22:44 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 85157 invoked by uid 99); 5 Nov 2013 13:22:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Nov 2013 13:22:20 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [193.74.71.27] (HELO eir.is.scarlet.be) (193.74.71.27) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Nov 2013 13:22:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scarlet.be; s=scarlet; t=1383657712; bh=tN8q/+WmAJfvVAkl/oy3eyMF684pL515uGoh+1kDFCk=; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Date:From:To: Subject:In-Reply-To:References:Message-ID; b=oRrQG4teTkGDLFna/AKBfgDOi9/O0M/8hWybmAp0nXliqnj45CXISanJu9UCSPdOF 7kaug/D6Zudl7L7G/sLzbujEH688gGTeo6cXZCX6Nwk8bNb/7uZUmAEKnUTiifHfcq TQafOdehns1J7G14evkixOVDqqXHaZouzYTZbzXE= Received: from webmail.scarlet.be (meigs.is.scarlet.be [193.74.71.216]) by eir.is.scarlet.be (8.14.5/8.14.5) with ESMTP id rA5DLpdq017808 for ; Tue, 5 Nov 2013 14:21:52 +0100 X-Scarlet: d=1383657712 c=193.74.71.216 Received: from astropc12.ulb.ac.be ([164.15.125.60]) via astropc12.ulb.ac.be ([164.15.125.60]) by webmail.scarlet.be with HTTP (HTTP/1.1 POST); Tue, 05 Nov 2013 14:21:51 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 05 Nov 2013 14:21:51 +0100 From: Gilles To: Subject: Re: [MATH] Interest in large patches for small cleanup / performance =?UTF-8?Q?changes=3F?= In-Reply-To: <5277F0ED.7050905@gmail.com> References: <868f896a9b0fec839efc24f3847d82ed@scarlet.be> <52752D17.2040003@gmail.com> <52769C5E.9070903@spaceroots.org> <5276ABF6.10602@spaceroots.org> <9ad805c2301511fe4771d5f53e84e27c@scarlet.be> <5276DD38.3000900@gmail.com> <178c2fe8add6e6fc126cc08e02f77655@scarlet.be> <52777218.1060102@spaceroots.org> <5277DDB4.1070205@gmail.com> <5277F0ED.7050905@gmail.com> Message-ID: <618e9921dc957cd8f29f3daf91d470be@scarlet.be> X-Sender: gilles@harfang.homelinux.org User-Agent: Scarlet Webmail X-DCC-scarlet.be-Metrics: eir; whitelist X-Virus-Scanned: clamav-milter 0.97.1-exp at eir X-Virus-Status: Clean X-Virus-Checked: Checked by ClamAV on apache.org >>> [...] >>> I have scanned for exact duplicates quite a few times and never >>> found any. There are quite a few that are similar, but differ in >>> material ways (strict versus non-strict inequalities, endpoints >>> included / not included, etc.). Please do not "collapse" messages >>> at the expense of loss of specificity or correctness. >> >> FAILED_BRACKETING >> UNABLE_TO_BRACKET_OPTIMUM_IN_LINE_SEARCH >> INVALID_BRACKETING_PARAMETERS > > Look at the messages. These are different. They convey different > information and are appropriate in different contexts. See below. I've argued that context information should be constructed at the point where the exception is thrown (where the context is known). Not all combinations of exceptions and context need be present in the pattern list. This is the essence of my proposal below. >> >> My position: the error (failed bracketing) should have its own >> exception >> type. The varying contexts could (do not have to) be part of the >> message >> built at exception instantiation. >> >> If we want to include an indication of location (despite it is >> already >> part of the stack trace, so it is _redundant_), we could perhaps >> add methods >> to the "ExceptionContext", e.g. "where(LocalizeFormats pattern)" >> (?). >> Then, we would have thos patterns in the list: >> >> BRACKETING >> LINE_SEARCH >> >> Note: INVALID and FAILED are redundant since the pattern is >> intended to be >> included in an exception. >> >> >> A second "interesting" case is >> >> INVALID_ROUNDING_METHOD >> >> which mixes documentation with error description. Does anyone >> really thinks >> that the enumeration of the rounding methods in the error message >> is necessary >> or even helpful? > > When I throw an exception, I want to provide an error message that > is meaningful in the context of the caller, i.e., that someone > looking at a log or stack trace can make sense of. That sometimes > means restating preconditions, sometimes pointing to boundary > conditions, sometimes giving hints describing common causes of the > exception - lots of different things that depend on the API, the > activation context and the nature of the exception. The natural way > to do this is to use natural language sentences. Please allow me to > retain a straightforward way to construct these messages and to > maintain the specificity and meaning of the messages. IMHO, the level of details in the message is not needed: if the exception was thrown, the user should probably look at the documentation, rather than try another value at random; I'd say that it is harmful to tempt the users with something like "Pick another number". ;-) [Shouldn't we rather provide function where the rounding type is an enum?] The main problem in those discussions is that you consider only "toy" situations, where the message generated by Commons Math should make sense wherever the exception is caught, and even if it is not caught. [I sometimes get a "failed bracketing" but knowing the values of "the endpoints [that] have the same sign" does not really help. I'd rather need to catch the exception, add more context info, rethrow, recatch, etc. And all this is quite more expensive than activating logging for those rare cases where numerical problems in the simulation trigger the exception.] Again and again, I do not mean that CM should not generate error messages, only that context info beyond a plain description of what happened is rarely usable a few layers above the failed call. And that context info could be provided with much less than 300+ different messages. Having little "building blocks" would also make it easier to retrieve pattern/value pairs, as Luc seems willing to do, and more stable, since a single placeholder is unlikely to change meaning, while a sentence that contains many, could be turned differently so that the previous placeholder index could now refer to a different value. Gilles --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org