title: Simple code to handle JNI exceptions
body: <p>I'd like to have a nice, tidy way of expressing the following java code as JNI:</p>
  
  <pre><code>try {
      SomeMethod ();
  }
  catch (ExceptionType1 e) {
      SomeAction ();
  }
  catch (ExceptionType2 e) {
      SomeAction ();
  }
  catch (ExceptionType3 e) {
      SomeAction ();
  }
  </code></pre>
  
  <p>Is there a tidy JNI patter for doing this?  At present, I have this:</p>
  
  <pre><code>java_class = (*env)-&gt;FindClass (env, EXCEPTION_CLASS_NAME);
  if (java_class == NULL) {
      *error_type_ref = ERROR_TYPE_FATAL;
      *exception_code_ref = EU_StrSprintf ("Class not found: %s", EXCEPTION_CLASS_NAME);
      cleanup ();
  }
  if ((*env)-&gt;IsInstanceOf (env, exception, java_class)) {
      SomeAction ();
      cleanup ();
  }
  </code></pre>
  
  <p>And, of course, this reoccurs for each exception so handled.  There has to be a better way.  Any recommendations?  I'm not interested in porting all of my existing code over to JNA, so I'd like a pattern that can be implemented home-grown, so to speak.</p>