summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2018-10-15 16:39:51 -0400
committerHenrik Edin <henrik.edin@mongodb.com>2018-10-25 09:27:55 -0400
commitacf51b090200d87cd0a74b25b1874294bcdca9bb (patch)
tree867db7fb029a7743f06de1a376e001f03cea15f9
parent3aebbb51ed5fe82601f601916251c5f892a59467 (diff)
downloadmongo-acf51b090200d87cd0a74b25b1874294bcdca9bb.tar.gz
SERVER-37513 Pass along Throwable in MongoEmbeddedCAPIException when available.
(cherry picked from commit 111748ec80485f6890487cc851f472dc4509b024)
-rw-r--r--src/mongo/embedded/mongo_embedded/java/build.gradle2
-rw-r--r--src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/CAPIHelper.java3
-rw-r--r--src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPI.java2
-rw-r--r--src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPIException.java20
4 files changed, 11 insertions, 16 deletions
diff --git a/src/mongo/embedded/mongo_embedded/java/build.gradle b/src/mongo/embedded/mongo_embedded/java/build.gradle
index 00e99ceb9fe..eef846ea0a6 100644
--- a/src/mongo/embedded/mongo_embedded/java/build.gradle
+++ b/src/mongo/embedded/mongo_embedded/java/build.gradle
@@ -12,9 +12,9 @@ ext.pomScmUrl = 'https://github.com/mongodb/mongo'
buildscript {
repositories {
+ google()
jcenter()
mavenCentral()
- google()
}
dependencies {
classpath 'com.netflix.nebula:gradle-extra-configurations-plugin:1.12.+'
diff --git a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/CAPIHelper.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/CAPIHelper.java
index f8266ff83cb..78b5f921aa7 100644
--- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/CAPIHelper.java
+++ b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/CAPIHelper.java
@@ -59,7 +59,8 @@ final class CAPIHelper {
final int errorCode) {
throw new MongoEmbeddedCAPIException(errorCode,
CAPI.mongo_embedded_v1_status_get_code(statusPointer),
- CAPI.mongo_embedded_v1_status_get_explanation(statusPointer).toString());
+ CAPI.mongo_embedded_v1_status_get_explanation(statusPointer).toString(),
+ null);
}
static void destroyStatusPointer(final CAPI.mongo_embedded_v1_status statusPointer) {
diff --git a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPI.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPI.java
index 30ecdf0956e..44595852ae2 100644
--- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPI.java
+++ b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPI.java
@@ -87,7 +87,7 @@ public final class MongoEmbeddedCAPI {
format("Unable to load the Mongo Embedded Library.%n"
+ "Please either: Set the libraryPath when calling MongoEmbeddedCAPI.create or %n"
+ "Ensure the library is set on the jna.library.path or the java.library.path system property."
- )
+ ), t
);
}
return new MongoEmbeddedLibraryImpl(yamlConfig != null ? yamlConfig : "", logLevel != null ? logLevel : LogLevel.LOGGER);
diff --git a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPIException.java b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPIException.java
index 4ffad8b6abb..95e8e8fd6a2 100644
--- a/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPIException.java
+++ b/src/mongo/embedded/mongo_embedded/java/src/com/mongodb/embedded/capi/MongoEmbeddedCAPIException.java
@@ -42,14 +42,6 @@ public class MongoEmbeddedCAPIException extends RuntimeException {
/**
* @param msg the message
- */
- public MongoEmbeddedCAPIException(final String msg) {
- super(msg);
- this.code = -1;
- }
-
- /**
- * @param msg the message
* @param cause the cause
*/
public MongoEmbeddedCAPIException(final String msg, final Throwable cause) {
@@ -60,21 +52,23 @@ public class MongoEmbeddedCAPIException extends RuntimeException {
/**
* @param code the error code
* @param msg the message
+ * @param cause the cause
*/
- public MongoEmbeddedCAPIException(final int code, final String msg) {
- super(msg);
+ public MongoEmbeddedCAPIException(final int code, final String msg, final Throwable cause) {
+ super(msg, cause);
this.code = code;
}
-
+
/**
* Constructs a new instance
*
* @param errorCode the error code
* @param subErrorCode the sub category error code
* @param reason the reason for the exception
+ * @param cause the cause
*/
- public MongoEmbeddedCAPIException(final int errorCode, final int subErrorCode, final String reason) {
- this(errorCode, format("%s (%s:%s)", reason, errorCode, subErrorCode));
+ public MongoEmbeddedCAPIException(final int errorCode, final int subErrorCode, final String reason, final Throwable cause) {
+ this(errorCode, format("%s (%s:%s)", reason, errorCode, subErrorCode), cause);
}
/**