Github user DaveBirdsall commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/31#discussion_r35014440
--- Diff: core/sql/langman/LmJavaExceptionReporter.cpp ---
@@ -792,3 +792,89 @@
LmJavaExceptionReporter::reportInternalSPJException(LmHandle jt,
}
// LCOV_EXCL_STOP
+
+//
+// reportJavaObjException(): populates the diags for
+// a return status returned in an LmUDRObjMethodInvoke.ReturnInfo
+// object used in the Java object interface
+void
+LmJavaExceptionReporter::processJavaObjException(
+ LmHandle returnInfoObj,
+ int returnStatus,
+ int callPhase,
+ const char *errText,
+ const char *udrName,
+ ComDiagsArea *da)
+{
+ if (da)
+ {
+ JNIEnv *jni = (JNIEnv*)jniEnv_;
+ const char *sqlState = NULL;
+ const char *message = NULL;
+ jobject jniResult = (jobject) returnInfoObj;
+ jstring returnedSQLState =
+ static_cast<jstring>(jni->GetObjectField(
+ jniResult,
+ (jfieldID) langMan_->getReturnInfoSQLStateField()));
+ jstring returnedMessage =
+ static_cast<jstring>(jni->GetObjectField(
+ jniResult,
+ (jfieldID) langMan_->getReturnInfoMessageField()));
+
+ if (returnedSQLState != NULL)
+ sqlState = jni->GetStringUTFChars(returnedSQLState, NULL);
+ if (returnedMessage != NULL)
+ message = jni->GetStringUTFChars(returnedMessage, NULL);
+
+ if (sqlState || message)
+ {
+ const char *diagsMessage =
+ (message ? message : "no message provided");
+ const char *diagsSQLState =
+ (sqlState ? sqlState : "no SQLSTATE provided");
+
+ // Check the returned SQLSTATE value and raise appropriate
+ // SQL code. Valid SQLSTATE values begin with "38" except "38000"
+ if (sqlState &&
+ (strncmp(diagsSQLState, "38", 2) == 0) &&
+ (strncmp(diagsSQLState, "38000", 5) != 0))
+ {
+ *da << DgSqlCode(-LME_CUSTOM_ERROR)
+ << DgString0(diagsMessage)
+ << DgString1(diagsSQLState);
+ *da << DgCustomSQLState(diagsSQLState);
+ }
+ else
+ {
+ *da << DgSqlCode(-LME_UDF_ERROR)
+ << DgString0(udrName)
+ << DgString1(diagsSQLState)
+ << DgString2(diagsMessage);
+ }
+ }
+ else
+ {
+ // Report the return status as an internal error, since
+ // we didn't get a UDRException. This should be rare, since
+ // Java exceptions are caught above.
+ char buf1[4];
+ snprintf(buf1, sizeof(buf1), "%d", callPhase);
+ char buf2[80];
+ snprintf(buf2, sizeof(buf2), "Return status %d from JNI call",
returnStatus);
--- End diff --
I've noticed that in the last year or so we are putting more message text
in our code (to avoid multiplying error messages in SqlciErrors.txt probably).
If there is ever a desire to translate our error messages into another
language, this will prove to be an obstacle.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---