if (Option.isEmpty(conversionWord)) {
inError = true;
errorMsg = "No 'conversionWord' attribute in <conversionRule>";
logger.warn(errorMsg);
ec.addError(new ErrorItem(errorMsg));
return;
}
if (Option.isEmpty(converterClass)) {
inError = true;
errorMsg = "No 'converterClass' attribute in <conversionRule>";
logger.warn(errorMsg);
ec.addError(new ErrorItem(errorMsg));
return;
}
try {
logger.debug(
"About to add conversion rule [" + conversionWord + ", "
+ converterClass + "] to layout");
Object o = ec.peekObject();
if (o instanceof PatternLayout) {
PatternLayout patternLayout = (PatternLayout) o;
patternLayout.addConversionRule(conversionWord, converterClass);
}
} catch (Exception oops) {
inError = true;
errorMsg = "Could not add conversion rule to PatternLayout.";
logger.error(errorMsg, oops);
ec.addError(new ErrorItem(errorMsg));
}
}