Raise TypeError if the config file is malformed

Fixes #1504.
I agree, I’ll raise a custom `TypeError`.