Skip to content

Commit

Permalink
Utilities/pkg: Print the line number of invalid entries
Browse files Browse the repository at this point in the history
  • Loading branch information
ninadsachania authored and nico committed Nov 2, 2024
1 parent c9badff commit 611b02d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Userland/Utilities/pkg/InstalledPortDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@ ErrorOr<NonnullOwnPtr<InstalledPortDatabase>> InstalledPortDatabase::instantiate
auto appending_database_file_descriptor = TRY(Core::File::open(path, Core::File::OpenMode::Write | Core::File::OpenMode::Append));
auto buffered_file = TRY(Core::InputBufferedFile::create(move(file)));
auto buffer = TRY(ByteBuffer::create_uninitialized(PAGE_SIZE));
int line_number = 0;

HashMap<String, InstalledPort> ports;
while (TRY(buffered_file->can_read_line())) {
auto line = TRY(buffered_file->read_line(buffer));
line_number += 1;
if (line.is_empty())
continue;

auto parts = line.split_view(' ');
if (parts.size() < 2) {
dbgln("Invalid database entry {} (only {} parts)", line, parts.size());
dbgln("Invalid database entry '{}' (only {} parts) on line {}", line, parts.size(), line_number);
continue;
}
auto install_type_string = parts[0];
Expand Down

0 comments on commit 611b02d

Please sign in to comment.