From eeb22f502884f7ebc130a4633051430ec30cf89e Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Thu, 8 Dec 2022 14:18:26 -0800 Subject: [PATCH] Simplify creation of exception messages --- src/main/java/com/maxmind/db/Decoder.java | 2 +- src/main/java/com/maxmind/db/Reader.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/maxmind/db/Decoder.java b/src/main/java/com/maxmind/db/Decoder.java index 5b4ba14d..3f69e325 100644 --- a/src/main/java/com/maxmind/db/Decoder.java +++ b/src/main/java/com/maxmind/db/Decoder.java @@ -448,7 +448,7 @@ private Object decodeMapIntoObject(int size, Class cls) + " Java Type: " +parameterTypes[index].getCanonicalName()); } } - throw new DeserializationException("Error creating object of type: " + cls.getSimpleName() + " - " + sbErrors.toString(), e); + throw new DeserializationException("Error creating object of type: " + cls.getSimpleName() + " - " + sbErrors, e); } } diff --git a/src/main/java/com/maxmind/db/Reader.java b/src/main/java/com/maxmind/db/Reader.java index 2837d81d..1bcb6000 100644 --- a/src/main/java/com/maxmind/db/Reader.java +++ b/src/main/java/com/maxmind/db/Reader.java @@ -184,8 +184,7 @@ record = this.readNode(buffer, record, bit); try { dataRecord = this.resolveDataPointer(buffer, record, cls); } catch (DeserializationException exception) { - String msgCause = Optional.ofNullable(exception).map(Exception::getMessage).orElse(""); - throw new DeserializationException("Error getting record for IP " + ipAddress.toString() + " - " + msgCause, exception); + throw new DeserializationException("Error getting record for IP " + ipAddress + " - " + exception.getMessage(), exception); } } return new DatabaseRecord<>(dataRecord, ipAddress, pl);