Move exceptions to their own package and subclass one class.

This commit is contained in:
Danila Fedorin 2017-09-07 13:05:16 -07:00
parent 52ab357fe1
commit 45de25cd50
9 changed files with 28 additions and 16 deletions

View File

@ -0,0 +1,9 @@
package org.nwapw.abacus.exception;
public class AbacusException extends RuntimeException {
public AbacusException(String baseMessage, String description){
super(baseMessage + ((description == null) ? "." : (": " + description)));
}
}

View File

@ -1,16 +1,16 @@
package org.nwapw.abacus.number;
package org.nwapw.abacus.exception;
/**
* Exception thrown when the computation is interrupted by
* the user.
*/
public class ComputationInterruptedException extends RuntimeException {
public class ComputationInterruptedException extends AbacusException {
/**
* Creates a new exception of this type.
*/
public ComputationInterruptedException() {
super("Computation interrupted.");
super("Computation interrupted", null);
}
}

View File

@ -1,24 +1,24 @@
package org.nwapw.abacus.function;
package org.nwapw.abacus.exception;
/**
* Exception thrown if the function parameters do not match
* requirements.
*/
public class DomainException extends RuntimeException {
public class DomainException extends AbacusException {
/**
* Creates a new DomainException.
* @param reason the reason for which the exception is thrown.
*/
public DomainException(String reason) {
super(reason);
super("Domain error", reason);
}
/**
* Creates a new DomainException with a default message.
*/
public DomainException(){
this("Domain error.");
this(null);
}
}

View File

@ -1,17 +1,17 @@
package org.nwapw.abacus.function;
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.
*/
public class EvaluationException extends RuntimeException {
public class EvaluationException extends AbacusException {
/**
* Creates a new EvaluationException with the default string.
*/
public EvaluationException() {
super("Evaluation error.");
this(null);
}
/**
@ -19,7 +19,7 @@ public class EvaluationException extends RuntimeException {
* @param message the message string.
*/
public EvaluationException(String message) {
super(message);
super("Evaluation error", message);
}
}

View File

@ -1,5 +1,7 @@
package org.nwapw.abacus.number;
import org.nwapw.abacus.exception.ComputationInterruptedException;
/**
* An interface used to represent a number.
*/

View File

@ -1,7 +1,7 @@
package org.nwapw.abacus.function.applicable
import org.nwapw.abacus.context.MutableEvaluationContext
import org.nwapw.abacus.function.DomainException
import org.nwapw.abacus.exception.DomainException
/**
* A class that can be applied to arguments.

View File

@ -2,7 +2,7 @@ package org.nwapw.abacus.tree
import org.nwapw.abacus.Abacus
import org.nwapw.abacus.context.EvaluationContext
import org.nwapw.abacus.function.EvaluationException
import org.nwapw.abacus.exception.EvaluationException
import org.nwapw.abacus.number.NumberInterface
class NumberReducer(val abacus: Abacus, context: EvaluationContext) : Reducer<NumberInterface> {

View File

@ -5,7 +5,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.nwapw.abacus.Abacus;
import org.nwapw.abacus.config.Configuration;
import org.nwapw.abacus.function.DomainException;
import org.nwapw.abacus.exception.DomainException;
import org.nwapw.abacus.number.NumberInterface;
import org.nwapw.abacus.plugin.StandardPlugin;
import org.nwapw.abacus.tree.TreeNode;

View File

@ -12,10 +12,11 @@ import javafx.util.Callback;
import javafx.util.StringConverter;
import org.nwapw.abacus.Abacus;
import org.nwapw.abacus.config.Configuration;
import org.nwapw.abacus.exception.ComputationInterruptedException;
import org.nwapw.abacus.function.Documentation;
import org.nwapw.abacus.function.DocumentationType;
import org.nwapw.abacus.function.DomainException;
import org.nwapw.abacus.function.EvaluationException;
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;