From a2dddef36d9a2e29deee36e96747b31a649a2051 Mon Sep 17 00:00:00 2001 From: Juerg Lang Date: Wed, 4 Oct 2023 11:19:03 +0200 Subject: [PATCH] refactoring --- .../github/jlangch/venice/impl/util/TimeUnitUtil.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/jlangch/venice/impl/util/TimeUnitUtil.java b/src/main/java/com/github/jlangch/venice/impl/util/TimeUnitUtil.java index a9bfb9e0c..cedd2fe13 100644 --- a/src/main/java/com/github/jlangch/venice/impl/util/TimeUnitUtil.java +++ b/src/main/java/com/github/jlangch/venice/impl/util/TimeUnitUtil.java @@ -30,6 +30,12 @@ public class TimeUnitUtil { public static TimeUnit toTimeUnit(final VncKeyword unit) { + if (unit == null) { + throw new VncException( + "No time-unit! " + + "Use one of :millis, :seconds, :minutes, :hours, :days."); + } + switch(unit.getValue()) { case "milli": return TimeUnit.MILLISECONDS; case "millis": return TimeUnit.MILLISECONDS; @@ -49,8 +55,8 @@ public static TimeUnit toTimeUnit(final VncKeyword unit) { default: throw new VncException( - "Invalid time-unit " + unit.getValue() + - "! Use one of :millis, :seconds, :minutes, :hours, :days."); + "Invalid time-unit " + unit.getValue() + "! " + + "Use one of :millis, :seconds, :minutes, :hours, :days."); } }