Skip to content

Commit

Permalink
added PreProcessorInputException#lineContents for better error-reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
BlvckBytes committed Oct 28, 2024
1 parent 3538674 commit b4123ae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ private PreProcessorLine parseLine(String line, int lineNumber, List<CommentLine
(keyChar >= '0' && keyChar <= '9') ||
keyChar == '-'
))
throw new PreProcessorInputException(lineNumber, InputConflict.INVALID_KEY_CHARACTERS);
throw new PreProcessorInputException(lineNumber, line, InputConflict.INVALID_KEY_CHARACTERS);
}

var valueBegin = indexOfWhitespace(line, keyEnd + 1, false);

if (valueBegin < 0)
throw new PreProcessorInputException(lineNumber, InputConflict.BLANK_VALUE);
throw new PreProcessorInputException(lineNumber, line, InputConflict.BLANK_VALUE);

var valueEnd = line.length() - 1;
var valueLength = valueEnd - valueBegin + 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
public class PreProcessorInputException extends RuntimeException {

public final int lineNumber;
public final String lineContents;
public final InputConflict conflict;

public PreProcessorInputException(int lineNumber, InputConflict conflict) {
public PreProcessorInputException(int lineNumber, String lineContents, InputConflict conflict) {
this.lineNumber = lineNumber;
this.lineContents = lineContents;
this.conflict = conflict;
}
}

0 comments on commit b4123ae

Please sign in to comment.