From f33eeb449422e1aebe5a8d99ebec3a36ee0a5f3f Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 6 Dec 2018 21:02:17 +0000 Subject: [PATCH] Return null rather than throwing an exception for unknown event type Closes gh-6 --- src/main/java/io/spring/issuebot/github/Event.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/spring/issuebot/github/Event.java b/src/main/java/io/spring/issuebot/github/Event.java index 623659c..f175bcd 100644 --- a/src/main/java/io/spring/issuebot/github/Event.java +++ b/src/main/java/io/spring/issuebot/github/Event.java @@ -20,6 +20,8 @@ import java.time.OffsetDateTime; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * An event that has been performed on an {@link Issue}. @@ -28,6 +30,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; */ public class Event { + private static final Logger log = LoggerFactory.getLogger(Event.class); + private final Type type; private final OffsetDateTime creationTime; @@ -220,8 +224,10 @@ public class Event { return value; } } - throw new IllegalArgumentException( - "'" + type + "' is not a valid event type"); + if (log.isInfoEnabled()) { + log.info("Received unknown event type '" + type + "'"); + } + return null; } }