Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Commit

Permalink
Output line numbers in errors / warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sfuhrm committed Jan 8, 2024
1 parent c73abdd commit 0cc57f1
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ private static Map<OID, Variable> readVariableBindings(final File walk, final Bu
OID lastOid = null;
String lastType = null;
String line;
int lineNumber = 0;
while ((line = reader.readLine()) != null) {
lineNumber++;
boolean match = false;
Matcher matcher = VARIABLE_BINDING_PATTERN.matcher(line);
if (matcher.matches()) {
Expand All @@ -100,9 +102,9 @@ private static Map<OID, Variable> readVariableBindings(final File walk, final Bu
}

bindings.put(oid, variable);
log.trace("added binding with oid \"{}\" and variable \"{}\"", oid, variable);
log.trace("added binding from line {} with oid \"{}\" and variable \"{}\"", lineNumber, oid, variable);
} catch (final Exception e) {
log.warn("could not parse line \"{}\" of walk file {} with exception: {}", line, walk.getCanonicalPath(), e.getMessage());
log.warn("could not parse line {} with \"{}\" of walk file {} with exception: {}", lineNumber, line, walk.getCanonicalPath(), e.getMessage());
}
}

Expand All @@ -121,7 +123,8 @@ private static Map<OID, Variable> readVariableBindings(final File walk, final Bu
String combined = oldString + "\n" + newString;
bindings.put(lastOid, new OctetString(combined));
} else {
log.warn("Could not find the previous octet string of OID {} in walk file {}", lastOid);
log.warn("Could not find the previous octet string of OID {} in walk file {} at line {}",
lastOid, walk.getAbsolutePath(), lineNumber);
}
}

Expand All @@ -139,13 +142,14 @@ private static Map<OID, Variable> readVariableBindings(final File walk, final Bu
System.arraycopy(newBytes, 0, combined, oldBytes.length, newBytes.length);
bindings.put(lastOid, new OctetString(combined));
} else {
log.warn("Could not find the previous octet string of OID {} in walk file {}", lastOid);
log.warn("Could not find the previous octet string of OID {} in walk file {} at line {}",
lastOid, walk.getAbsolutePath(), lineNumber);
}
}
}

if (!match) {
log.warn("could not parse line \"{}\" of walk file {}", line, walk.getAbsolutePath());
log.warn("Could not parse line number {} with content \"{}\" of walk file {}", lineNumber, line, walk.getAbsolutePath());
}
}
return bindings;
Expand Down

0 comments on commit 0cc57f1

Please sign in to comment.