Exceptions in KDE Frameworks

Michael Pyne mpyne at kde.org
Fri Nov 1 22:41:43 UTC 2013


On Fri, November 1, 2013 17:30:02 Mirko Boehm wrote:
> Hi,
> 
> in ThreadWeaver, I would like to be able to catch exceptions thrown from the
> run() method of Jobs. You know we cannot trust the user :-) I can work
> around if exceptions are disabled in the compiler if I know about it. What
> I would like to be able to do is
> 
> a) catch JobAborted and JobFailed exceptions thrown by the user, and set the
> job's status accordingly, b) catch other unhandled exceptions, print an
> error message and re-throw them. Unhandled exceptions in the worker thread
> basically mean the end of the program, as far as I am concerned, but I
> would like to be able to exit cleanly.
> 
> Two questions:
> 
> 1) Are we sure we want to disable exceptions in libraries released in 2014?
> 2) What is the _BLBAFASEL_EXCEPTIONS_ENABLED_ preprocessor variable that I
> can use to implemented the exception- and non-exception based code paths?

KSharedDataCache uses exceptions now. This is only in its own code so as not 
to bloat the rest of kdelibs for users who don't want exception support, but 
I'd say if it makes your code easier, to go for it.

AFAIK the only reason to avoid exceptions is an increase in code size, which 
doesn't strike me as a strong problem in 2014. But on the other hand it might 
still be an issue for embedded platforms, which I'm sure we'd want to support.

I don't know the defines for it though, sorry.

Regards,
 - Michael Pyne
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20131101/eaef3066/attachment.sig>


More information about the Kde-frameworks-devel mailing list