Error message truncation

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Error message truncation

Michael Chirico
Help pages for stop/warning reference the option "warning.length", e.g.
from ?stop:

Errors will be truncated to getOption("warning.length") characters, default
> 1000.

Essentially the same is in ?warning.

Neither of these mention the hard-coded limits on the acceptable values of
this option in options.c

if (streql(CHAR(namei), "warning.length")) {
  int k = asInteger(argi);
  if (k < 100 || k > 8170)
  error(_("invalid value for '%s'"), CHAR(namei));
  R_WarnLength = k;
  SET_VECTOR_ELT(value, i, SetOption(tag, argi));

Further, it appears there's a physical limit on the length of the error
message itself which is only slightly larger than 8170:

NN = 10000L
str = paste(sample(letters, NN, TRUE), collapse = '')
# should of course be 10000
tryCatch(stop(str), error = function(e) nchar(e$message))
# [1] 8190

My questions are:

   - Can we add some information to the help pages indicating valid values
   of options('warning.length')?
   - Is there any way to increase the limit on error message length? I
   understand having such a limit is safer than potentially crashing a system
   that wants to print a massive error string.

This came up in relation to this SO Q&A:

The user is submitting a database query; the error message will first
reproduce the entirety of the query and then give some diagnostic
information. Queries can get quite long, so it stands to reason that this
8190-length limit might be binding.

Michael Chirico

        [[alternative HTML version deleted]]

[hidden email] mailing list