improve error message on class constraint check failure