Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: A chained e...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 8 of 8 Topic 9566 of 9807
Post > Topic >>

Re: A chained exception (base) class for C++

by Martin T <0xCDCDCDCD@[EMAIL PROTECTED] > May 2, 2008 at 12:47 PM

nickf3 wrote:
> On Apr 30, 12:43 pm, "Martin T." <0xCDCDC...@[EMAIL PROTECTED]
> wrote:
>> Hi all,
>>
>> I'm currently trying to come up with a decent exception base class for
>> some modules of ours and was thinking about adding exception-chaining
>> (yes, like in Java :-)
>> The following points where im****tant for me:
>> * Must inherit from std::exception
>> * Should allow for a std::exception to be the start of the exception
chain.
>> * throw by value / catch by const reference
>>
>> As exception chaining seems to be rather obscure with C++, I'm
>> interested what other think about the solution (find code below).
>>
>> thanks,
>> br,
>> Martin
>>
> 
> Martin,
> 
> I'm wondering what's the value of having such chained exceptions
> besides being able to print the [imprecise] call stack? Then you

Well, a "call stack" was never the intent. I'd have to catch on every
function in between ... *****ver* ... :-)
The value of it is that it makes rethrowing on different application
layers painless. Often we'd have some root-cause being either as std
exception or a simple error-code in the lowest module. Typically this
will pass one or two layers where it will be caught and rethrowing the
same exception is inappropriate. As I don't want to loose the inital
information I need some form of chaining.

> don't event use __FILE__/__LINE__, so unless I'm missing something
> obvious, I see no point in all this additional work.
> 

Well, in the end I would and probably will use a construct making use of
  __FILE__ __LINE__ __FUNCTION__ - I just did not want to clutter the
posted example with it.

cheers,
Martin

-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 8 Posts in Topic:
A chained exception (base) class for C++
"Martin T." <  2008-04-30 10:43:22 
Re: A chained exception (base) class for C++
=?UTF-8?B?RXJpayBXaWtzdHL  2008-04-30 17:05:07 
Re: A chained exception (base) class for C++
Greg Herlihy <greghe@[  2008-04-30 22:19:30 
Re: A chained exception (base) class for C++
Martin T <0xCDCDCDCD@[  2008-05-01 13:14:31 
Re: A chained exception (base) class for C++
Eugene Gershnik <gersh  2008-05-02 04:43:58 
Re: A chained exception (base) class for C++
nickf3 <nickf3@[EMAIL   2008-05-02 04:44:00 
Re: A chained exception (base) class for C++
Martin T <0xCDCDCDCD@[  2008-05-02 12:48:14 
Re: A chained exception (base) class for C++
Martin T <0xCDCDCDCD@[  2008-05-02 12:47:51 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 19 19:46:00 CDT 2008.