You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-dev@logging.apache.org by Tommi Maekitalo <to...@epgmbh.de> on 2004/10/06 09:35:48 UTC

Exception - std::exception

Hi,

I would like to see ::log4cxx::Exception derived from ::std::exception.

The problem is, that ::log4cxx::String might be wide-character. The message of 
Exception must be converted by the constructor of Exception to std::string.

What do you think?


Tommi

Re: Exception - std::exception

Posted by Tommi Mäkitalo <to...@epgmbh.de>.
Am Mittwoch, 6. Oktober 2004 18:12 schrieb Curt Arnold:
> > Defering is good, but I would derive Exception from runtime_error,
> > which needs
> > a std::string in constructor, so the conversion need to be done in the
> > constructor.
> >
> > Another possible solution is to use runtime_error, give the
> > constructor a
> > empty string and override what().
>
> I'd suggest doing in the constructor at least for now.  I might be able
> to tweak it when doing the Unicode rework if it appears to be a
> significant performance issue.
Ok, here is the patch against current CVS.

The string is converted in the constructor. In case String is defined as 
std::string, there is no conversion done at all.

I tested it with g++-3.3.3.

Tommi

Re: Exception - std::exception

Posted by Curt Arnold <ca...@houston.rr.com>.
> Defering is good, but I would derive Exception from runtime_error, 
> which needs
> a std::string in constructor, so the conversion need to be done in the
> constructor.
>
> Another possible solution is to use runtime_error, give the 
> constructor a
> empty string and override what().
>

I'd suggest doing in the constructor at least for now.  I might be able 
to tweak it when doing the Unicode rework if it appears to be a 
significant performance issue.


Re: Exception - std::exception

Posted by Tommi Maekitalo <to...@epgmbh.de>.
Am Mittwoch, 6. Oktober 2004 12:34 schrieb Christophe de VIENNE:
> I'd see the convertion more in what() than in the constructor. The
> reason for that is that such operation should be defered as possible, if
> done at all (not using what() will avoid completely the convertion)
>
> >What do you think?
>
> Only good thing. I'd vote +1 to do this modification.
>
>
> Regards,
>
> Christophe
Defering is good, but I would derive Exception from runtime_error, which needs 
a std::string in constructor, so the conversion need to be done in the 
constructor.

Another possible solution is to use runtime_error, give the constructor a 
empty string and override what().


Tommi

Re: Exception - std::exception

Posted by Christophe de VIENNE <cd...@alphacent.com>.
Tommi Maekitalo wrote:

>Hi,
>
>I would like to see ::log4cxx::Exception derived from ::std::exception.
>
>The problem is, that ::log4cxx::String might be wide-character. The message of 
>Exception must be converted by the constructor of Exception to std::string.
>  
>
I'd see the convertion more in what() than in the constructor. The 
reason for that is that such operation should be defered as possible, if 
done at all (not using what() will avoid completely the convertion)

>What do you think?
>  
>
Only good thing. I'd vote +1 to do this modification.


Regards,

Christophe