Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should reprex output add new lines with long (wide) error & warning messages? #413

Open
EconomiCurtis opened this issue Mar 26, 2022 · 1 comment
Labels
feature a feature request or enhancement

Comments

@EconomiCurtis
Copy link

EconomiCurtis commented Mar 26, 2022

When a reprex output shows a long warning or error message, it does not add new lines consistent with typical experience with character max-widths from the R console.

For example, (perhaps an odd example, but it's one I recently used on RStudio Community)

library(dplyr)
df <- tibble(
  y = LETTERS[1:3],
  x1 = 1:3,
  x2 = 3:5
)
lm(y ~ x1 + x2, data = df)

this produces a somewhat long error,

#> Warning in storage.mode(v) <- "double": NAs introduced by coercion
#> Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...): NA/NaN/Inf in 'y'

In the console, this appears as the following,
Screenshot R Console:
image

On Stack Overflow, this appears as the following (not you have to scroll left to see the full error)
Screenshot Stack Overflow:
image

Screenshot RStudio Community:
image

That horizontal scrolling can be awkward for some folks. Particularly for long errors and warnings (e.g. some package install errors). I feel it'd be ideal for warning and error messages to roughly replicate the new lines seen in the R console.

New lines can certainly be added manually -- I have a feeling there are other concerns or trickiness I'm missing -- but I feel the default behavior should be with styling that works better on gh, so, and rstudio community.

@jennybc
Copy link
Member

jennybc commented Aug 14, 2022

Links from a bit of searching on this:

yihui/knitr#1142 has advice on "customize the error/warning hook function to wrap the error/warning message"

A hack Hadley has used in book-y projects to wrap errors and warnings: https://github.com/hadley/adv-r/blob/dc49c3872c3530ac08716fd4f4c235b01266a4ce/common.R#L44-L64

@cderv Do you have any quick input? As in, is there some simple knitr option I could use to wrap errors and warnings? I suspect not.

@jennybc jennybc added the feature a feature request or enhancement label Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants