Don't silently eat invalid document types.

Instead throw an exception.