Add more descriptive errors to `doc/diag.py`

@sustrik, do you mean something like this?

The patch is submitted under MIT License