Skip to content

Commit

Permalink
Let transform throw a runtime exception instead of checked exception (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
querdenker2k authored Dec 30, 2022
1 parent 9371e84 commit b9a7076
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
package org.openhab.automation.jrule.internal.handler;

import org.openhab.automation.jrule.exception.JRuleExecutionException;
import org.openhab.automation.jrule.exception.JRuleRuntimeException;
import org.openhab.core.transform.TransformationException;
import org.openhab.core.transform.TransformationHelper;
import org.osgi.framework.BundleContext;
Expand Down Expand Up @@ -50,11 +50,19 @@ public void setBundleContext(BundleContext bundleContext) {
this.bundleContext = bundleContext;
}

public String transform(String stateDescPattern, String state) throws JRuleExecutionException {
/**
* Transforms the given state with the transformation pattern.
*
* @param stateDescPattern The transformation pattern
* @param state State which should be converted
* @return The transformation result
* @throws JRuleRuntimeException In case a transformation exception occur
*/
public String transform(String stateDescPattern, String state) throws JRuleRuntimeException {
try {
return TransformationHelper.transform(bundleContext, stateDescPattern, state);
} catch (TransformationException e) {
throw new JRuleExecutionException(
throw new JRuleRuntimeException(
String.format("Transformation of %s using %s failed: %s", state, stateDescPattern, e));
}
}
Expand Down

0 comments on commit b9a7076

Please sign in to comment.