Make error message generation a bit more generic