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

Error message out of order? #39

Closed
hadley opened this issue Sep 21, 2023 · 6 comments · Fixed by #40
Closed

Error message out of order? #39

hadley opened this issue Sep 21, 2023 · 6 comments · Fixed by #40
Labels
bug an unexpected problem or unintended behavior

Comments

@hadley
Copy link
Collaborator

hadley commented Sep 21, 2023

pandoc::pandoc_convert("20230428 Brians Story v3.docx", from = "word", to = "markdown")
#> Unknown input format word
#> Error in `pandoc_run()`:
#> ! Running Pandoc failed with following error
#> Run `rlang::last_trace()` to see where the error occurred.

It took me a minute to figure out the error because it's preceding, not following.

@cderv
Copy link
Owner

cderv commented Sep 22, 2023

Thanks. I need to review my usage of rlang::abort() then 🤔

pandoc/R/pandoc-run.R

Lines 24 to 28 in ee86163

res <- suppressWarnings(system2(bin, args, stdout = TRUE))
status <- attr(res, "status", TRUE)
if (length(status) > 0 && status > 0) {
rlang::abort(c("Running Pandoc failed with following error", res))
}

@cderv
Copy link
Owner

cderv commented Sep 22, 2023

Though this is what I see....

> xfun::write_utf8("dummy", "test.md")
> pandoc_convert("test.md", from = "markdown", to = "word")
Error in `pandoc_run()` at pandoc/R/pandoc-convert.R:64:2:
! Running Pandoc failed with following errorUnknown output format word
Run `rlang::last_trace()` to see where the error occurred.

In which context do you see the above ?

In reprex I am missing a line message it seems...

xfun::write_utf8("dummy", "test.md")
pandoc::pandoc_convert("test.md", from = "markdown", to = "word")
#> Error in `pandoc_run()`:
#> ! Running Pandoc failed with following error
#> Backtrace:
#>     ▆
#>  1. └─pandoc::pandoc_convert("test.md", from = "markdown", to = "word")
#>  2.   └─pandoc::pandoc_run(args, version = version)
#>  3.     └─rlang::abort(...)

Created on 2023-09-22 with reprex v2.0.2

@cderv
Copy link
Owner

cderv commented Sep 22, 2023

Ok - I can reproduce on Linux. So probably the same on Mac.

@cderv cderv added the bug an unexpected problem or unintended behavior label Sep 22, 2023
@cderv
Copy link
Owner

cderv commented Sep 22, 2023

This is about message capture for Pandoc output. It is not working the same on Windows and Linux.

On windows

> xfun::write_utf8("dummy", "test.md")
> system2(fs::path_expand(pandoc::pandoc_bin()), c("--to", "word", "test.md"), stdout = TRUE)
[1] "Unknown output format word"
attr(,"status")
[1] 22
Message d'avis :
Dans system2(fs::path_expand(pandoc::pandoc_bin()), c("--to", "word",  :
  l'exécution de la commande '"C:/Users/chris/AppData/Local/r-pandoc/r-pandoc/3.1.8/pandoc.exe" --to word test.md' renvoie un statut 22

On Linux

❯ system2(fs::path_expand(pandoc::pandoc_bin()), c("--to", "word", "test.md"), stdout = TRUE)
Unknown output format word
character(0)
attr(,"status")
[1] 22
Warning message:
In system2(fs::path_expand(pandoc::pandoc_bin()), c("--to", "word",  :
  running command ''/home/cderv/.local/share/r-pandoc/2.16.2/pandoc' --to word test.md' had status 22

I need stderr = TRUE here obviously, but the difference in behavior between OS for R is quite disturbing... 🤔

cderv added a commit that referenced this issue Sep 22, 2023
So that the error can be shown within `rlang::abort()` correctly

fixes #39
cderv added a commit that referenced this issue Sep 22, 2023
So that the error can be shown within `rlang::abort()` correctly

fixes #39
@cderv cderv closed this as completed in #40 Sep 22, 2023
@cderv
Copy link
Owner

cderv commented Sep 22, 2023

Thanks ! this is fixed in dev version now.

@hadley
Copy link
Collaborator Author

hadley commented Sep 22, 2023

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants