Skip to content

Commit 379075f

Browse files
committed
exception messages detailed
1 parent a8942e9 commit 379075f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

powertools-serialization/src/main/java/software/amazon/lambda/powertools/utilities/EventDeserializer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public <T> T as(Class<T> clazz) {
188188
throw new EventDeserializationException("The content of this event is a list, consider using 'asListOf' instead");
189189
}
190190
// should not occur, except if the event is malformed (missing fields)
191-
throw new IllegalStateException("Event content is null");
191+
throw new IllegalStateException("Event content is null: the event may be malformed (missing fields)");
192192
} catch (IOException e) {
193193
throw new EventDeserializationException("Cannot load the event as " + clazz.getSimpleName(), e);
194194
}
@@ -206,7 +206,7 @@ public <T> List<T> asListOf(Class<T> clazz) {
206206
throw new EventDeserializationException("The content of this event is not a list, consider using 'as' instead");
207207
}
208208
// should not occur, except if the event is really malformed
209-
throw new IllegalStateException("Event content is null");
209+
throw new IllegalStateException("Event content is null: the event may be malformed (missing fields)");
210210
}
211211
return contentList.stream().map(s -> {
212212
try {

powertools-serialization/src/test/java/software/amazon/lambda/powertools/utilities/EventDeserializerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void testDeserializeSQSEventBodyAsWrongObjectType_shouldThrowException(SQ
129129
public void testDeserializeAPIGatewayNoBody_shouldThrowException(APIGatewayProxyRequestEvent event) {
130130
assertThatThrownBy(() -> extractDataFrom(event).as(Product.class))
131131
.isInstanceOf(IllegalStateException.class)
132-
.hasMessage("Event content is null");
132+
.hasMessageContaining("Event content is null");
133133
}
134134

135135
@ParameterizedTest

0 commit comments

Comments
 (0)