Alan D. Cabrera a écrit :
On Jan 19, 2010, at 7:31 AM, Ashish wrote:
Well I think only Exception could be the only case needed. However,
catching generic Exception means any error, a specific Exception
caught is better.
The other odd thing is that it catches the checked exception and wraps
it in a runtime exception. This strikes me as a poor practice.
To say the least ...
Added on
http://svn.apache.org/viewvc/mina/trunk/transport-apr/src/main/java/org/apache/mina/transport/socket/apr/AprIoProcessor.java?r1=593014&r2=596587
Why am I not surprised ? ...
Here, tomcat-APR just throw a java.lang.Exception instance, not a
Runtime or an Error :
http://svn.apache.org/viewvc/tomcat/native/tags/TOMCAT_NATIVE_1_1_19/native/src/error.c?revision=896054&view=markup
/*
39 * Convenience function to help throw an java.lang.Exception.
40 */
41 void tcn_ThrowException(JNIEnv *env, const char *msg)
42 {
43 jclass javaExceptionClass;
44
45 javaExceptionClass = (*env)->FindClass(env,
"java/lang/Exception");
46 if (javaExceptionClass == NULL) {
47 fprintf(stderr, "Cannot find java/lang/Exception class\n");
48 return;
49 }
50 (*env)->ThrowNew(env, javaExceptionClass, msg);
51 (*env)->DeleteLocalRef(env, javaExceptionClass);
52
53 }
We can simply catch it and do whatever we want with it.