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 messages format #12

Open
noeliarico opened this issue Feb 18, 2021 · 6 comments
Open

Error messages format #12

noeliarico opened this issue Feb 18, 2021 · 6 comments

Comments

@noeliarico
Copy link

Hi!

First of all, congratulations for this release. This package has all the xaringan related functions I've been wanting for.

I just have a suggestion regarding the format of the error messages. I guess some of them are quite easy to understand for developers but they may not be to the wide public to which I'm sure this package is aimed.

In my first contact with the package I tried to compile the template obtained from xaringanthemer to PDF.

> library(xaringanBuilder)
> build_pdf("myslides.html")
✓ Building slides.pdf from slides.html ... done
Error in pagedown::chrome_print(input = input, output = output_file) : 
  The browser is not executable: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

The error was obviously because I didn't have Google Chrome installed. Maybe a message indicating that this browser must be installed should be given.

I installed it and then get:

> build_pdf("myslides.html")
✓ Building slides.pdf from slides.html ... done
Error in is_remote_protocol_ok(debug_port, verbose = verbose) : 
  Cannot find headless Chrome after 20 attempts

I was executing the code before opening Google Chrome (again, if this is necessary maybe it should be shown in a message). After opening Google Chrome I executed the code again. The slides were correct but I got an error though (which this time I could not understand).

> build_pdf("myslides.html")
✓ Building slides.pdf from slides.html ... done
[2021-02-18 09:58:56] [error] handle_read_frame error: asio.system:54 (Connection reset by peer)

One of the slides runs out of the frame (it also does in the html version). May that be the reason?

@jhelvy
Copy link
Owner

jhelvy commented Feb 18, 2021

Thanks for this! Right now I don't have a convenient way to determine if the user has Chrome installed or not. It's been requested in this issue in the chromote package. If that gets implemented then I can use it to provide better error messages with respect to the required Chrome installation.

The handle_read_frame error message is one I've seen before, and I believe it does have to do with whether a slide runs out of the frame, though I haven't tested it carefully. Even though it says "error" the slides still build, so I think it really should just be a warning message. Can you provide code for a simple .Rmd xaringan slide deck that produces that error message?

@noeliarico
Copy link
Author

For the message about the installation of Google Chrome maybe you could add a try/catch in your build_pdf_simple function in the pdf.R file, so if the function pagedown::chrome_print returns the error The browser is not executable you can print your own message telling people to install Chrome.

I also believe the problem handle_read_frame error is that the frame is too small for its content. In the code I left in the first comment, myslides.html are the ones obtained from the template of the xaringan themer (where this problem with the frame happens around the slide 30, with the title "Themes").

So you can install.packages("xaringanthemer") and then File (New) > R Markdown > From Template > Ninja Themed Presentation and knit this into myslides.html. Then try my code in the first comment and you should get the [error].

@jhelvy
Copy link
Owner

jhelvy commented Feb 18, 2021

There will be multiple situations where a missing Chrome installation will cause an error, so I'd rather not set the error messaging based on any one particular error message. The better fix would be to run a check for whether Chrome is installed right at the start and post the message there before pagedown::chrome_print is ever called. Until I can do that, I might just have a general warning message post every time pagedown::chrome_print is called to help with debugging.

I'll try the default slides from xaringanthemer.

@jhelvy
Copy link
Owner

jhelvy commented Feb 18, 2021

Okay, thanks to @wch the find_chrome() function is now accessible from the chromote library, so I added an assert_chrome_installed() function with d8e5781 to hopefully throw an error if Chrome isn't detected.

Still need to address the other error message though about slides running out of the frame.

@gadenbuie
Copy link
Collaborator

The slides were correct but I got an error though (which this time I could not understand).

> build_pdf("myslides.html")
✓ Building slides.pdf from slides.html ... done
[2021-02-18 09:58:56] [error] handle_read_frame error: asio.system:54 (Connection reset by peer)

One of the slides runs out of the frame (it also does in the html version). May that be the reason?

The error message here comes from chromote, or more likely directly from the headless Chrome instance. It certainly is cryptic but I'm not sure if there's anything that could be done about it, other than possibly to suppress it and return a generic error. (I'm not sure that's a great idea; sometimes there are small hints in those error messages).

Most likely, there was an issue with loading the page or an image that caused that error. It certainly isn't related to the slide content in any way. I can reproduce a similar issue that I'll submit separately.

@jhelvy
Copy link
Owner

jhelvy commented Jul 13, 2021

I've had trouble reproducing the issue as it seemed to spuriously occur when I was testing for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants