Fixes #2691. More descriptive exception message.