Some custom Exceptions and fix to .format calls.

This commit fixes a bug with .format specification for some exceptions
throwing a ValueError('cannot switch from manual field specification to
automatic field numbering') instead of the Exception to be thrown.

Switching to custom exceptions to hopefully be more informative and to
avoid the test cases not picking up problems like a different ValueError
exception being thrown instead of the expected Exception.