|
From: | John W. Eaton |
Subject: | Re: Using exceptions in the core |
Date: | Wed, 07 Oct 2015 10:40:43 -0400 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 |
On 10/07/2015 02:06 AM, Olaf Till wrote:
On Tue, Oct 06, 2015 at 11:15:00PM -0400, Mike Miller wrote:I still think it's a little weird to say "convert to a string for me, here's an error message just in case", is there really no better way?What occured to me now, though maybe a mad idea and much more work, is overloading as ..._value (..., bool& err) (somehow avoiding to have the same signature as the existing functions), and for this variant not to throw, but to set 'err' to true. This wholly avoids the try/catch, leaves the user the resposibility to check 'err', but only in the cases where he explicitely requested it by using this overloaded variant.
So you would have to write bool err = false; value_type val = arg.value_extractor (err); if (err) error ("error message here"); I see that as no better than either value_type val; try { arg.value_extractor (); } catch { error ("error message here"); } or value_type val = arg.value_extractor ("error message here"); The last option is certainly more concise. jwe
[Prev in Thread] | Current Thread | [Next in Thread] |