Skip to content

Commit d200527

Browse files
more logging
1 parent d1caf75 commit d200527

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

lambdas/upsert-letter/src/handler/upsert-handler.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,13 @@ function mapToUpdateLetter(upsertRequest: LetterEvent): UpdateLetter {
114114
function getType(event: unknown) {
115115
const env = TypeEnvelope.safeParse(event);
116116
if (!env.success) {
117-
throw new Error("Missing or invalid envelope.type field");
117+
// Helpful debugging info:
118+
const pretty = (() => {
119+
return JSON.stringify(event, null, 2);
120+
})();
121+
throw new Error(
122+
`Missing or invalid envelope.type field. Payload seen:\n${pretty}`,
123+
);
118124
}
119125
return env.data.type;
120126
}

0 commit comments

Comments
 (0)