I have a shell script that runs chromium-browser headless, using it to print html into a pdf file.
$ chromium-browser --headless --disable-gpu \
--print-to-pdf=/home/www-data/build/out.pdf \
/home/www-data/build/out.html
If there are any errors with the page (anything from Javascript errors to unavailable resources), I would like my shell script to behave accordingly. But how do I even tell if such errors occur?
Below is a screenshot from Chromium, where an environment variable was not set, and therefore the path for the CSS files is incorrect.
I have tried in various ways to get this information out of chrome headless, but without luck.
My best suggestion is to look for it in the log in userdata, but even with the highest logging level, I don't see that there is anything about not being able to log the resources. All I can find about loading those resources is shown below:
$ rm /home/www-data/userdata -rf
$ chromium-browser --headless --disable-gpu \
--enable-logging
--v=4 \
--user-data-dir=/home/www-data/userdata \
--print-to-pdf=/home/www-data/build/out.pdf \
/home/www-data/build/out.html
$ grep css userdata -r
userdata/Default/chrome_debug.log:[0921/163104.096612:VERBOSE1:file_url_loader_factory.cc(451)] FileURLLoader::Start: file:///css/bootstrap.css
userdata/Default/chrome_debug.log:[0921/163104.096746:VERBOSE1:file_url_loader_factory.cc(451)] FileURLLoader::Start: file:///css/email.css
userdata/Default/chrome_debug.log:[0921/163104.096873:VERBOSE1:file_url_loader_factory.cc(451)] FileURLLoader::Start: file:///css/print_common.css
userdata/Default/chrome_debug.log:[0921/163104.097021:VERBOSE1:file_url_loader_factory.cc(451)] FileURLLoader::Start: file:///css/print_A4P.css
