[commit] r1829 - in trunk/SDK/Java: . java/org/isis/jaut native/Jaut

GMESRC Repository Notifications gme-commit at list.isis.vanderbilt.edu
Fri Feb 10 15:49:15 CST 2012


Author: ksmyth
Date: Fri Feb 10 15:49:15 2012
New Revision: 1829

Log:
Add detail message to exception when GetIDOfName fails due to DISP_E_UNKNOWNNAME

Modified:
   trunk/SDK/Java/gme.jar
   trunk/SDK/Java/java/org/isis/jaut/ComException.java
   trunk/SDK/Java/native/Jaut/Dispatch.cpp
   trunk/SDK/Java/native/Jaut/Library.cpp
   trunk/SDK/Java/native/Jaut/Library.h

Modified: trunk/SDK/Java/gme.jar
==============================================================================
Binary file (source and/or target). No diff available.

Modified: trunk/SDK/Java/java/org/isis/jaut/ComException.java
==============================================================================
--- trunk/SDK/Java/java/org/isis/jaut/ComException.java	Fri Feb 10 15:48:51 2012	(r1828)
+++ trunk/SDK/Java/java/org/isis/jaut/ComException.java	Fri Feb 10 15:49:15 2012	(r1829)
@@ -51,6 +51,8 @@
 	 * The <code>HRESULT</code> value.
 	 */
 	protected int hResult;
+	
+	protected final String detail;
 
 	/**
 	 * Creates an exception for a COM error code.
@@ -60,6 +62,13 @@
 	public ComException(int hResult)
 	{
 		this.hResult = hResult;
+		this.detail = null;
+	}
+
+	public ComException(int hResult, String detail)
+	{
+		this.hResult = hResult;
+		this.detail = detail;
 	}
 
 	/**
@@ -87,7 +96,7 @@
 
 //		msg = msg.replaceAll("\r\n", " ");
 
-		return msg + "(0x" + Integer.toHexString(hResult) +")";
+		return msg + "(0x" + Integer.toHexString(hResult) + ")" + (detail == null ? "" : " " + detail);
 	}
 
 	/**

Modified: trunk/SDK/Java/native/Jaut/Dispatch.cpp
==============================================================================
--- trunk/SDK/Java/native/Jaut/Dispatch.cpp	Fri Feb 10 15:48:51 2012	(r1828)
+++ trunk/SDK/Java/native/Jaut/Dispatch.cpp	Fri Feb 10 15:49:15 2012	(r1829)
@@ -421,7 +421,9 @@
 
 	env->ReleaseStringChars(name, (const jchar*)n);
 	
-	if( FAILED(hr) )
+	if (hr == DISP_E_UNKNOWNNAME)
+		ThrowComExceptionString(env, hr, name);
+	else if( FAILED(hr) )
 		ThrowComException(env, hr);
 
 	return id;

Modified: trunk/SDK/Java/native/Jaut/Library.cpp
==============================================================================
--- trunk/SDK/Java/native/Jaut/Library.cpp	Fri Feb 10 15:48:51 2012	(r1828)
+++ trunk/SDK/Java/native/Jaut/Library.cpp	Fri Feb 10 15:49:15 2012	(r1829)
@@ -48,6 +48,7 @@
 
 jclass JAUT_ComException_Class = NULL;
 jmethodID JAUT_ComException_Constructor;
+jmethodID JAUT_ComException_Constructor_IString;
 
 jclass JAUT_InvokeException_Class = NULL;
 jmethodID JAUT_InvokeException_Constructor;
@@ -95,6 +96,10 @@
 		JAUT_ComException_Constructor = env->GetMethodID(JAUT_ComException_Class, 
 			"<init>", "(I)V");
 
+	if( JAUT_ComException_Class != NULL )
+		JAUT_ComException_Constructor_IString = env->GetMethodID(JAUT_ComException_Class, 
+			"<init>", "(ILjava/lang/String;)V");
+
 	if( JAUT_ComException_Class == NULL || JAUT_ComException_Constructor == NULL )
 		return JNI_ERR;
 
@@ -199,7 +204,7 @@
 		env->Throw(exc);
 }
 
-void ThrowComException(JNIEnv *env, HRESULT hr)
+void ThrowComExceptionString(JNIEnv *env, HRESULT hr, jstring detail)
 {
 	if( hr == E_OUTOFMEMORY )
 	{
@@ -207,13 +212,21 @@
 		return;
 	}
 
-	jthrowable exc = (jthrowable)env->NewObject(JAUT_ComException_Class, 
-		JAUT_ComException_Constructor, (jint)hr);
+	jthrowable exc;
+	if (detail != NULL && JAUT_ComException_Constructor_IString != NULL)
+		exc = (jthrowable)env->NewObject(JAUT_ComException_Class, JAUT_ComException_Constructor_IString, (jint)hr, detail);
+	else 
+		exc = (jthrowable)env->NewObject(JAUT_ComException_Class, JAUT_ComException_Constructor, (jint)hr);
 
 	if( exc != NULL )
 		env->Throw(exc);
 }
 
+void ThrowComException(JNIEnv *env, HRESULT hr)
+{
+	ThrowComExceptionString(env, hr, NULL);
+}
+
 void ThrowInvokeException(JNIEnv* env, EXCEPINFO *info)
 {
 	if( info->pfnDeferredFillIn != NULL )

Modified: trunk/SDK/Java/native/Jaut/Library.h
==============================================================================
--- trunk/SDK/Java/native/Jaut/Library.h	Fri Feb 10 15:48:51 2012	(r1828)
+++ trunk/SDK/Java/native/Jaut/Library.h	Fri Feb 10 15:49:15 2012	(r1829)
@@ -75,6 +75,7 @@
 
 void ThrowJAutException(JNIEnv *env, const char *desc);
 void ThrowComException(JNIEnv *env, HRESULT hr);
+void ThrowComExceptionString(JNIEnv *env, HRESULT hr, jstring detail);
 void ThrowInvokeException(JNIEnv* env, EXCEPINFO *info);
 void ThrowOutOfMemoryError(JNIEnv* env);
 void ThrowNullPointerException(JNIEnv* env);


More information about the gme-commit mailing list