Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit c8bc5b7

Browse files
committed
#153: Including the templateBatchInsert script in error message
Intent is to help user debug the error as the Java Client does not get the actual error message, nor is it in the ML error logs.
1 parent 5216eb5 commit c8bc5b7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/main/java/com/marklogic/client/ext/schemasloader/impl/DefaultSchemasLoader.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ private void loadTdeTemplatesViaBatchInsert(List<DocumentFile> tdeFiles) {
133133
try {
134134
schemasDatabaseClient.newServerEval().javascript(script.toString()).eval().close();
135135
} catch (Exception ex) {
136-
throw new RuntimeException("Unable to load and validate TDE templates via tde.templateBatchInsert; cause: " + ex.getMessage(), ex);
136+
throw new RuntimeException("Unable to load and validate TDE templates via tde.templateBatchInsert; " +
137+
"cause: " + ex.getMessage() + "; the following script can be run in Query Console against your content " +
138+
"database to see the TDE validation error:\n" + script, ex);
137139
}
138140
}
139141

src/test/java/com/marklogic/client/ext/schemasloader/impl/ValidateTdeTemplatesTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public void badJsonFile() {
3030
final String path = Paths.get("src", "test", "resources", "bad-schemas", "bad-json").toString();
3131
if (TdeUtil.templateBatchInsertSupported(client)) {
3232
RuntimeException ex = assertThrows(RuntimeException.class, () -> loader.loadSchemas(path));
33+
assertTrue(ex.getMessage().contains("the following script can be run in Query Console against your content " +
34+
"database to see the TDE validation error"), "Unexpected message: " + ex.getMessage());
3335
FailedRequestException fre = (FailedRequestException)ex.getCause();
3436
assertTrue(fre.getMessage().contains("failed to apply resource at eval: Internal Server Error"),
3537
"Unfortunately, the FailedRequestException does not capture why the tde.templateBatchInsert failed; " +
@@ -63,6 +65,8 @@ public void badXmlFile() {
6365
final String path = Paths.get("src", "test", "resources", "bad-schemas", "bad-xml").toString();
6466
if (TdeUtil.templateBatchInsertSupported(client)) {
6567
RuntimeException ex = assertThrows(RuntimeException.class, () -> loader.loadSchemas(path));
68+
assertTrue(ex.getMessage().contains("the following script can be run in Query Console against your content " +
69+
"database to see the TDE validation error"), "Unexpected message: " + ex.getMessage());
6670
FailedRequestException fre = (FailedRequestException)ex.getCause();
6771
assertTrue(fre.getMessage().contains("failed to apply resource at eval: Internal Server Error"),
6872
"Unfortunately, the FailedRequestException does not capture why the tde.templateBatchInsert failed; " +

0 commit comments

Comments
 (0)