Hi Housam, On Mon, Nov 13, 2023 at 8:49 PM Aaron Merey <ame...@redhat.com> wrote: > > On Wed, Nov 8, 2023 at 11:49 AM Housam Alamour <halam...@redhat.com> wrote: > > + /* Read the file contents and write it to the zip file */ > > + fd = open(file_path.c_str(), O_RDONLY); > > + if (!fd) > > + { > > + cerr << "Error: Failed to open the file: " << file_path << endl; > > + continue; > > + } > [...] > As for error messages, right now we don't actually print "Failed to > open...". open returns -1 on error, but we only print when fd == 0. > So we want to print an error message when fd == -1 instead. > > There are other sources of error messages that we could include, like > stat and read. libarchive and debuginfod_find_source provide error codes > too. > > IMO if -v is given we should print detailed error messages whenever > a file can't be acquired. Errno and strerror are useful for this. Otherwise > if -v isn't given then we can simply print the "Failed to open file" message.
I came up with a slightly better way to handle error messages after giving this some more thought. How about if -v isn't given, then print no messages re. file availability, error or otherwise. And if -v is given then we print a detailed message for each file either confirming its availability or giving the reason it couldn't be acquired. This approach is less noisy when files can't be found for mundane reasons but it also provides comprehensive details on each file when the user asks for it. Aaron