From eba653d0d712e43676e28f93b7cba217cb56cecc Mon Sep 17 00:00:00 2001 From: "Benjamin J. Culkin" Date: Tue, 11 Jun 2019 22:28:51 -0300 Subject: Initial commit p2 The rest of the files, for initial upload to github --- src/main/java/bjc/replpair/ReplError.java | 56 +++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/main/java/bjc/replpair/ReplError.java (limited to 'src/main/java/bjc/replpair/ReplError.java') diff --git a/src/main/java/bjc/replpair/ReplError.java b/src/main/java/bjc/replpair/ReplError.java new file mode 100644 index 0000000..9d0fe02 --- /dev/null +++ b/src/main/java/bjc/replpair/ReplError.java @@ -0,0 +1,56 @@ +package bjc.replpair; + +/** + * Represents an error encountered parsing ReplPairs + * + * @author Ben Culkin + */ +public class ReplError { + /** + * The line the error occured on. + */ + public int line; + /** + * The number of pairs we have processed so far. + */ + public int numPairs; + + /** + * The text of the line we errored on. + */ + public String txt; + /** + * The message of the error. + */ + public String msg; + + /** + * Create a new ReplPair parse error. + * + * @param lne + * The line the error occured on. + * @param nPairs + * The number of pairs processed up to this point. + * @param msg + * The message detailing the error. + * @param txt + * The text that caused the error. + */ + public ReplError(int lne, int nPairs, String msg, String txt) { + line = lne; + numPairs = nPairs; + + this.txt = txt; + this.msg = msg; + } + + @Override + public String toString() { + String errString; + if (txt == null) errString = "No associated line"; + else if (txt.equals("")) errString = "Text of line was empty"; + else errString = "Text of line was: " + txt; + + return String.format("line %d, pair %d:%s\n\t%s", line, numPairs, msg, errString); + } +} -- cgit v1.2.3