From a22918f82504289685cf805b32c59ae8f29c4d84 Mon Sep 17 00:00:00 2001 From: vstepanov Date: Thu, 1 Nov 2018 11:35:02 +0100 Subject: [PATCH] ARUHA-1997: Extended the catched exception range; --- .../zalando/nakadi/repository/db/EventTypeDbRepository.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/zalando/nakadi/repository/db/EventTypeDbRepository.java b/src/main/java/org/zalando/nakadi/repository/db/EventTypeDbRepository.java index 3a0edafdf1..80854910db 100644 --- a/src/main/java/org/zalando/nakadi/repository/db/EventTypeDbRepository.java +++ b/src/main/java/org/zalando/nakadi/repository/db/EventTypeDbRepository.java @@ -6,7 +6,7 @@ import org.joda.time.DateTimeZone; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataAccessException; -import org.springframework.dao.DuplicateKeyException; +import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; @@ -15,9 +15,9 @@ import org.zalando.nakadi.annotations.DB; import org.zalando.nakadi.domain.EventType; import org.zalando.nakadi.domain.EventTypeBase; +import org.zalando.nakadi.exceptions.runtime.DuplicatedEventTypeNameException; import org.zalando.nakadi.exceptions.runtime.InternalNakadiException; import org.zalando.nakadi.exceptions.runtime.NoSuchEventTypeException; -import org.zalando.nakadi.exceptions.runtime.DuplicatedEventTypeNameException; import org.zalando.nakadi.repository.EventTypeRepository; import java.io.IOException; @@ -49,7 +49,7 @@ public EventType saveEventType(final EventTypeBase eventTypeBase) throws Interna return eventType; } catch (final JsonProcessingException e) { throw new InternalNakadiException("Serialization problem during persistence of event type", e); - } catch (final DuplicateKeyException e) { + } catch (final DataIntegrityViolationException e) { throw new DuplicatedEventTypeNameException("EventType " + eventTypeBase.getName() + " already exists.", e); } }