safe loading of calculator engine
This commit is contained in:
parent
4dae4bbca4
commit
b7b32b1002
@ -179,13 +179,26 @@ public class CalculatorEngineImpl implements CalculatorEngine {
|
||||
@Override
|
||||
public void reset() {
|
||||
synchronized (lock) {
|
||||
varsRegistry.load();
|
||||
functionsRegistry.load();
|
||||
operatorsRegistry.load();
|
||||
postfixFunctionsRegistry.load();
|
||||
safeLoadRegistry(varsRegistry);
|
||||
safeLoadRegistry(functionsRegistry);
|
||||
safeLoadRegistry(operatorsRegistry);
|
||||
safeLoadRegistry(postfixFunctionsRegistry);
|
||||
}
|
||||
}
|
||||
|
||||
private void safeLoadRegistry(@Nonnull CalculatorMathRegistry<?> registry) {
|
||||
try {
|
||||
registry.load();
|
||||
} catch (Exception e) {
|
||||
logException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void logException(@Nonnull Exception e) {
|
||||
final CalculatorLogger logger = Locator.getInstance().getLogger();
|
||||
logger.error("Engine", e.getMessage(), e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void softReset() {
|
||||
Locator.getInstance().getCalculator().fireCalculatorEvent(CalculatorEventType.engine_preferences_changed, null);
|
||||
|
Loading…
Reference in New Issue
Block a user