Skip to content

Commit

Permalink
Added error handling to transform
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex committed Nov 16, 2023
1 parent 6424f17 commit c9e0486
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,16 @@ class MBeanHelper {

Object getBeanAttributeWithTransform(GroovyMBean bean, String attribute){
def transformationClosure = attributeTransformation.get(attribute);
return transformationClosure != null ? transformationClosure(bean) : getBeanAttribute(bean, attribute)
if (transformationClosure != null){
try{
transformationClosure(bean)
}
catch(AttributeNotFoundException e){
logger.warning("Transformed attribute not found in ${bean.name()}")
null
}
}
return getBeanAttribute(bean, attribute)
}

static Object getBeanAttribute(GroovyMBean bean, String attribute) {
Expand Down

0 comments on commit c9e0486

Please sign in to comment.