Commit 2d2a10b5 authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Merge branch 'nkoptimizeloadwitherrorlines' into 'master'

Added history display if file load fails

See merge request !20
parents c67b9fea c0282e9f
......@@ -226,6 +226,7 @@ sub loadFile
# Loop again with each line number
my $line_current = 0;
my $percent_last = "";
my @history = ();
while (my $cmdline = <$FH>) {
# Bump line number
$line_current++;
......@@ -246,9 +247,21 @@ sub loadFile
# Process
if ((my $res = processCommand($OUT,$cmdline)) < 0) {
print($OUT " => Failed to execute command on line $line_current: $cmdline\n");
# List last 5 success lines
foreach my $line (@history) {
print($OUT " => SUCCESS: $line\n");
}
# Lastly list the failure
print($OUT " => FAILURE: $cmdline\n");
return $res;
}
# Store history so we can give better errors
push(@history,$cmdline);
# Store only 5 lines of history
if (@history > 5) {
shift(@history);
}
}
# Close
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment