From ba8ad7754989799e503fdf74e359df5e5700da6c Mon Sep 17 00:00:00 2001 From: Chip Kent Date: Fri, 12 Jan 2024 10:36:01 -0700 Subject: [PATCH] Better error logging when calendars do not load. --- .../time/calendar/BusinessCalendarXMLParser.java | 2 +- .../java/io/deephaven/time/calendar/Calendars.java | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendarXMLParser.java b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendarXMLParser.java index 05de3ee6223..0d1220a6c51 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendarXMLParser.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/BusinessCalendarXMLParser.java @@ -141,7 +141,7 @@ private static Element getRequiredChild(@NotNull final Element root, final Strin if (element != null) { return element; } else { - throw new Exception("Missing the '" + child + "' tag in calendar file: text=" + root.getText()); + throw new Exception("Missing the '" + child + "' tag in calendar file: text=" + root.getTextTrim()); } } diff --git a/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java b/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java index 9bd510992b0..50b640cc4cc 100644 --- a/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java +++ b/engine/time/src/main/java/io/deephaven/time/calendar/Calendars.java @@ -63,8 +63,11 @@ private static void loadProperty(final Configuration configuration, final String final String location = configuration.getProperty(property); try { load(location); - } catch (NoSuchFileException e) { - logger.warn().append("Problem loading calendars. importPath=").append(location).append(e).endl(); + } catch (Exception e) { + logger.warn().append("Problem loading calendars. property=").append(property) + .append(" importPath=").append(location).append(e).endl(); + throw new RuntimeException("Problem loading calendars. property=" + property + + " importPath=" + location, e); } } @@ -90,7 +93,7 @@ private static void load(final String businessCalendarConfig) throws NoSuchFileE logger.warn("Could not open " + filePath + " from classpath"); throw new RuntimeException("Could not open " + filePath + " from classpath"); } - } catch (IOException e) { + } catch (Exception e) { logger.warn("Problem loading calendar: location=" + businessCalendarConfig, e); throw new RuntimeException("Problem loading calendar: location=" + businessCalendarConfig, e); } @@ -98,10 +101,7 @@ private static void load(final String businessCalendarConfig) throws NoSuchFileE try (final BufferedReader config = new BufferedReader(new InputStreamReader(configToLoad))) { config.lines().forEach(consumer); - } catch (NoSuchFileException e) { - logger.warn("Problem loading calendar: location=" + businessCalendarConfig, e); - throw e; - } catch (IOException e) { + } catch (Exception e) { logger.warn("Problem loading calendar: location=" + businessCalendarConfig, e); throw new RuntimeException("Problem loading calendar: location=" + businessCalendarConfig, e); }