diff --git a/core/src/main/java/org/nwapw/abacus/exception/NumberReducerException.java b/core/src/main/java/org/nwapw/abacus/exception/NumberReducerException.java new file mode 100644 index 0000000..694e0bf --- /dev/null +++ b/core/src/main/java/org/nwapw/abacus/exception/NumberReducerException.java @@ -0,0 +1,25 @@ +package org.nwapw.abacus.exception; + +/** + * Exception thrown by the NumberReducer if something goes wrong when + * transforming a parse tree into a single value. + */ +public class NumberReducerException extends AbacusException { + + /** + * Creates a new NumberReducerException with + * no additional message. + */ + public NumberReducerException() { + this(""); + } + + /** + * Creates a new NumberReducerException with the given message. + * @param message the message. + */ + public NumberReducerException(String message) { + super("Error evaluating expression", message); + } + +} diff --git a/core/src/main/java/org/nwapw/abacus/exception/EvaluationException.java b/core/src/main/java/org/nwapw/abacus/exception/ReductionException.java similarity index 51% rename from core/src/main/java/org/nwapw/abacus/exception/EvaluationException.java rename to core/src/main/java/org/nwapw/abacus/exception/ReductionException.java index 5eed066..d9173a6 100644 --- a/core/src/main/java/org/nwapw/abacus/exception/EvaluationException.java +++ b/core/src/main/java/org/nwapw/abacus/exception/ReductionException.java @@ -1,16 +1,14 @@ package org.nwapw.abacus.exception; /** - * An exception thrown primarily from Tree Value operators and functions, - * which have to deal with the result of a Reducer as well as the results - * of Applicable. + * An exception thrown from TreeReducers. */ -public class EvaluationException extends AbacusException { +public class ReductionException extends AbacusException { /** * Creates a new EvaluationException with the default string. */ - public EvaluationException() { + public ReductionException() { this(""); } @@ -18,7 +16,7 @@ public class EvaluationException extends AbacusException { * Creates a new EvaluationError with the given message string. * @param message the message string. */ - public EvaluationException(String message) { + public ReductionException(String message) { super("Evaluation error", message); } diff --git a/core/src/main/kotlin/org/nwapw/abacus/tree/NumberReducer.kt b/core/src/main/kotlin/org/nwapw/abacus/tree/NumberReducer.kt index 80d79cd..1d9885a 100644 --- a/core/src/main/kotlin/org/nwapw/abacus/tree/NumberReducer.kt +++ b/core/src/main/kotlin/org/nwapw/abacus/tree/NumberReducer.kt @@ -2,7 +2,8 @@ package org.nwapw.abacus.tree import org.nwapw.abacus.Abacus import org.nwapw.abacus.context.EvaluationContext -import org.nwapw.abacus.exception.EvaluationException +import org.nwapw.abacus.exception.NumberReducerException +import org.nwapw.abacus.exception.ReductionException import org.nwapw.abacus.number.NumberInterface class NumberReducer(val abacus: Abacus, context: EvaluationContext) : Reducer { @@ -24,7 +25,7 @@ class NumberReducer(val abacus: Abacus, context: EvaluationContext) : Reducer { val child = children[0] as NumberInterface @@ -57,7 +58,7 @@ class NumberReducer(val abacus: Abacus, context: EvaluationContext) : Reducer throw EvaluationException("unrecognized tree node.") + else -> throw ReductionException("unrecognized tree node.") } } diff --git a/fx/src/main/java/org/nwapw/abacus/fx/AbacusController.java b/fx/src/main/java/org/nwapw/abacus/fx/AbacusController.java index f903618..8c4700d 100644 --- a/fx/src/main/java/org/nwapw/abacus/fx/AbacusController.java +++ b/fx/src/main/java/org/nwapw/abacus/fx/AbacusController.java @@ -13,11 +13,8 @@ import javafx.util.StringConverter; import org.nwapw.abacus.Abacus; import org.nwapw.abacus.config.Configuration; import org.nwapw.abacus.exception.AbacusException; -import org.nwapw.abacus.exception.ComputationInterruptedException; import org.nwapw.abacus.function.Documentation; import org.nwapw.abacus.function.DocumentationType; -import org.nwapw.abacus.exception.DomainException; -import org.nwapw.abacus.exception.EvaluationException; import org.nwapw.abacus.number.*; import org.nwapw.abacus.plugin.ClassFinder; import org.nwapw.abacus.plugin.PluginListener;