summaryrefslogtreecommitdiff
path: root/src/main/java/bjc/replpair/ReplError.java
diff options
context:
space:
mode:
authorBenjamin J. Culkin <bjculkin@mix.wvu.edu>2019-06-11 22:28:51 -0300
committerBenjamin J. Culkin <bjculkin@mix.wvu.edu>2019-06-11 22:28:51 -0300
commiteba653d0d712e43676e28f93b7cba217cb56cecc (patch)
tree1d5849556c99a5bbcc955e217296e5fdf9f990e6 /src/main/java/bjc/replpair/ReplError.java
parent71c35c0ffba04e7c7932ffa06b9528b2a5efb48d (diff)
Initial commit p2
The rest of the files, for initial upload to github
Diffstat (limited to 'src/main/java/bjc/replpair/ReplError.java')
-rw-r--r--src/main/java/bjc/replpair/ReplError.java56
1 files changed, 56 insertions, 0 deletions
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);
+ }
+}