correctly raise exceptions when parsing invalid mode strings