From d86cbcbabc4b251956bd2c5bf4dfa459a00bb239 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Tue, 18 Jun 2019 17:44:32 -0400 Subject: Lots of frontend work --- src/main/java/bjc/everge/ReplError.java | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/main/java/bjc/everge/ReplError.java') 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 @@ -24,6 +24,22 @@ public class ReplError { */ 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(IntHolder lne, IntHolder nPairs, String msg, String txt) { + this(lne.get(), nPairs.get(), msg, txt); + } + /** * Create a new ReplPair parse error. * @@ -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); + } } -- cgit v1.2.3