mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[jrubyscripting] log Ruby stacktrace on exception from JRuby (#13778)
Signed-off-by: Cody Cutrer <cody@cutrer.us>
This commit is contained in:
parent
ea134d8215
commit
4739f126a2
@ -199,7 +199,7 @@ public class JRubyScriptEngineConfiguration {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -221,7 +221,7 @@ public class JRubyScriptEngineConfiguration {
|
||||
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));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -239,7 +239,7 @@ public class JRubyScriptEngineConfiguration {
|
||||
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));
|
||||
}
|
||||
});
|
||||
|
||||
@ -267,7 +267,7 @@ public class JRubyScriptEngineConfiguration {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -293,6 +293,20 @@ public class JRubyScriptEngineConfiguration {
|
||||
.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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user