Skip to content

Commit

Permalink
Better error logging when calendars do not load.
Browse files Browse the repository at this point in the history
  • Loading branch information
chipkent committed Jan 12, 2024
1 parent d11f342 commit ba8ad77
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -90,18 +93,15 @@ 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);
}
};

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);
}
Expand Down

0 comments on commit ba8ad77

Please sign in to comment.