traversc / qs

Quick serialization of R objects
397 stars 19 forks source link

feature request: report filename when giving warnings #75

Closed HedvigS closed 5 months ago

HedvigS commented 1 year ago

I use qs functions to read in many files in loop/apply/map_df. It would be beneficial if warnings (like the checksum checks) also reported the file where the breakage happened, even if it's "just" a warning and not a full error.

traversc commented 1 year ago

Hello, I've added the file name to relevant warnings and errors. You can test it like this:

library(qs)

# Print file name on checksum error
x <- qserialize(1, preset = "uncompressed")
x[length(x)] <- as.raw(255)
writeBin(x, con = "/tmp/temp.qs")
qread("/tmp/temp.qs")

# Warning: In file /tmp/temp.qs: Hash checksum does not match (Recorded, Computed) (4292153937,47518289), data may be corrupted

# print filename for missing file
qread("file_does_not_exist.qs")

# For file file_does_not_exist.qs: Failed to open for reading...

Hopefully will be on CRAN soon

HedvigS commented 5 months ago

Lovely! Thank you @traversc !