Skip to content

Commit

Permalink
fully different message for warning vs. error
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico authored Sep 26, 2024
1 parent 4c9cfb3 commit 30d1201
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions R/fread.R
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,14 @@ yaml=FALSE, autostart=NA, tmpdir=tempdir(), tz="UTC")
# finally:
methods::as(v, new_class))
},
warning = fun <- function(e) {
warningf("Column '%s' was requested to be '%s' but fread encountered the following %s:\n\t%s\nso the column has been left as type '%s'", names(ans)[j], new_class, if (inherits(e, "error")) gettext("error") else gettext("warning"), e$message, typeof(v))
warning = fun <- function(c) {
# NB: branch here for translation purposes (e.g. if error/warning have different grammatical gender)
if (inherits(c, "warning")) {
msg_fmt <- gettext("Column '%s' was requested to be '%s' but fread encountered the following warning:\n\t%s\nso the column has been left as type '%s'")
} else {
msg_fmt <- gettext("Column '%s' was requested to be '%s' but fread encountered the following error:\n\t%s\nso the column has been left as type '%s'")
}
warningf(msg_fmt, names(ans)[j], new_class, conditionMessage(c), typeof(v), domain=NA)
v
},
error = fun)
Expand Down

0 comments on commit 30d1201

Please sign in to comment.