ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vladimir Ozerov <voze...@gridgain.com>
Subject C++ exception handling strategy.
Date Mon, 01 Jun 2015 08:42:15 GMT

In Java our API extensively use exceptions to signal faulty conditions. The
same technique must be applied somehow to C++ API as well.

The most obvious solution for our Java minds is to simply throw exceptions
in C++ as well. But this solution doesn't seem to be valid for C++ world:
1) User will inject varoius resources into our lib (e.g. allocators,
serializers, closures). Throwing excpetino will make memory management
extremely tough from user perspective.
2) Throwing exceptions across module boundaries is considered to be a bad
practice from both portability and usability standpoints (e.g. we do not
want user app to crash due to, say, CachePartialUpdateException).
3) Exceptions might be disabled explicitly for some apps.

I propose to use the same approach as WinAPI, JNI and lots other libraries
do: never throw exceptions, but rather have a separate function to check
for previous error. This function will return the last error occurred in
the thread (if any).

(functions ExceptionOccurred, ExceptionCheck)

Please share your thoughts regarding the matter.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message