Skip to content

Commit 8362d6e

Browse files
committed
Including Redis Enterprise error details in http response exception.
Resolves #2
1 parent a82a474 commit 8362d6e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

subprojects/admin/src/main/java/com/redis/enterprise/Admin.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,7 @@ private <T> T read(ClassicHttpRequest request, JavaType type, int successCode) t
177177
if (response.getCode() == successCode) {
178178
return objectMapper.readValue(json, type);
179179
}
180-
log.error("Error: {}", json);
181-
throw new HttpResponseException(response.getCode(), response.getReasonPhrase());
180+
throw new HttpResponseException(response.getCode(), response.getReasonPhrase() + " " + json);
182181
}
183182

184183
public List<Module> getModules() throws ParseException, IOException {

subprojects/admin/src/test/java/com/redis/enterprise/AdminTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.stream.Collectors;
88
import java.util.stream.Stream;
99

10+
import org.apache.hc.client5.http.HttpResponseException;
1011
import org.apache.hc.core5.http.ParseException;
1112
import org.awaitility.Awaitility;
1213
import org.junit.jupiter.api.AfterAll;
@@ -18,6 +19,7 @@
1819
import org.junit.jupiter.api.TestInstance.Lifecycle;
1920
import org.slf4j.Logger;
2021
import org.slf4j.LoggerFactory;
22+
import org.springframework.util.unit.DataSize;
2123
import org.testcontainers.junit.jupiter.Container;
2224
import org.testcontainers.junit.jupiter.Testcontainers;
2325

@@ -87,4 +89,10 @@ void installModule() throws IOException, ParseException {
8789
}
8890
}
8991

92+
@Test
93+
void databaseCreateException() throws ParseException, IOException {
94+
Assertions.assertThrows(HttpResponseException.class, () -> admin.createDatabase(
95+
Database.name("DatabaseCreateExceptionTestDB").memory(DataSize.ofGigabytes(10)).build()));
96+
}
97+
9098
}

0 commit comments

Comments
 (0)