logger.trace("Gem install code:\n{}", gemCommand);
engine.eval(gemCommand);
} catch (ScriptException e) {
- logger.warn("Error installing Gems: {}", e.getMessage());
+ logger.warn("Error installing Gems", unwrap(e));
}
}
logger.trace("Injecting require statement: {}", requireStatement);
engine.eval(requireStatement);
} catch (ScriptException e) {
- logger.warn("Error evaluating statement {}: {}", requireStatement, e.getMessage());
+ logger.warn("Error evaluating `{}`", requireStatement, unwrap(e));
}
});
}
logger.trace("Setting Ruby environment with code: {} ", environmentSetting);
engine.eval(environmentSetting);
} catch (ScriptException e) {
- logger.warn("Error setting ruby environment", e);
+ logger.warn("Error setting Ruby environment", unwrap(e));
}
});
try {
engine.eval(code);
} catch (ScriptException exception) {
- logger.warn("Error setting $LOAD_PATH from RUBYLIB='{}': {}", rubyLib.get(), exception.getMessage());
+ logger.warn("Error setting $LOAD_PATH from RUBYLIB='{}'", rubyLib.get(), unwrap(exception));
}
}
}
.filter(element -> element.getValue().isPresent());
}
+ /**
+ * Unwraps the cause of an exception, if it has one.
+ *
+ * Since a user cares about the _Ruby_ stack trace of the throwable, not
+ * the details of where openHAB called it.
+ */
+ private Throwable unwrap(Throwable e) {
+ Throwable cause = e.getCause();
+ if (cause != null) {
+ return cause;
+ }
+ return e;
+ }
+
/**
* Inner static companion class for configuration elements
*/