improve error messages when possible