summaryrefslogtreecommitdiff
path: root/src/main/java/bjc/everge/ReplError.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/bjc/everge/ReplError.java')
-rw-r--r--src/main/java/bjc/everge/ReplError.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/main/java/bjc/everge/ReplError.java b/src/main/java/bjc/everge/ReplError.java
index e5a4dd0..6e58539 100644
--- a/src/main/java/bjc/everge/ReplError.java
+++ b/src/main/java/bjc/everge/ReplError.java
@@ -36,6 +36,22 @@ public class ReplError {
* @param txt
* The text that caused the error.
*/
+ public ReplError(IntHolder lne, IntHolder nPairs, String msg, String txt) {
+ this(lne.get(), nPairs.get(), msg, txt);
+ }
+
+ /**
+ * 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;
@@ -53,4 +69,18 @@ public class ReplError {
return String.format("line %d, pair %d:%s\n\t%s", line, numPairs, msg, errString);
}
+
+ public String toPrintString() {
+ return toPrintString("");
+ }
+
+ public String toPrintString(String hdr) {
+ 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("[ERROR] line %d, pair %d: %s\n%s\tContext: %s",
+ line, numPairs, msg, hdr, errString);
+ }
}