Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. #define CATCH_CPP_EXCEPTION_AND_THROW_JAVA_EXCEPTION \
  2. \
  3. catch (const std::bad_alloc& e) \
  4. { \
  5. /* OOM exception */ \
  6. jclass jc = env->FindClass("java/lang/OutOfMemoryError"); \
  7. if(jc) env->ThrowNew (jc, e.what()); \
  8. } \
  9. catch (const std::ios_base::failure& e) \
  10. { \
  11. /* IO exception */ \
  12. jclass jc = env->FindClass("java/io/IOException"); \
  13. if(jc) env->ThrowNew (jc, e.what()); \
  14. } \
  15. catch (const std::exception& e) \
  16. { \
  17. /* unknown exception */ \
  18. jclass jc = env->FindClass("java/lang/Error"); \
  19. if(jc) env->ThrowNew (jc, e.what()); \
  20. } \
  21. catch (...) \
  22. { \
  23. /* Oops I missed identifying this exception! */ \
  24. jclass jc = env->FindClass("java/lang/Error"); \
  25. if(jc) env->ThrowNew (jc, "unidentified exception"); \
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement