Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define CATCH_CPP_EXCEPTION_AND_THROW_JAVA_EXCEPTION \
- \
- catch (const std::bad_alloc& e) \
- { \
- /* OOM exception */ \
- jclass jc = env->FindClass("java/lang/OutOfMemoryError"); \
- if(jc) env->ThrowNew (jc, e.what()); \
- } \
- catch (const std::ios_base::failure& e) \
- { \
- /* IO exception */ \
- jclass jc = env->FindClass("java/io/IOException"); \
- if(jc) env->ThrowNew (jc, e.what()); \
- } \
- catch (const std::exception& e) \
- { \
- /* unknown exception */ \
- jclass jc = env->FindClass("java/lang/Error"); \
- if(jc) env->ThrowNew (jc, e.what()); \
- } \
- catch (...) \
- { \
- /* Oops I missed identifying this exception! */ \
- jclass jc = env->FindClass("java/lang/Error"); \
- if(jc) env->ThrowNew (jc, "unidentified exception"); \
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement