tidy-html5 unfortunately conflates any I/O errors with rule warnings, making it rather difficult to obtain a meaningful error code.
We can capture the output (stdin and/or stdout) and grep it for the message Document: "(anything here)" is not a file!
That may not catch all I/O errors, for example read errors or broken pipe errors. But it's a start.
Eventually may be worth publishing the tidy_up wrapper as its own separate project and dependency of this project.