Error messages should be informative, actionable, and concise to help users quickly understand and fix issues. Follow these guidelines: 1. Include specific details in error messages:
Error messages should be informative, actionable, and concise to help users quickly understand and fix issues. Follow these guidelines:
# Avoid
raise ValueError('Invalid axis: {} not in range {}-{}'.format(axis, min_val, max_val))
# Prefer
raise ValueError(f"Argument `axis` = {axis} not in range [{min_val}, {max_val})")
# Too verbose
raise ValueError(f'Python found at {python_bin_path} is not version 3. Please update to the latest version to continue with installation.')
# Better
raise ValueError(f'Python from {python_bin_path} is not version 3.')
# Vague
raise ValueError("Type annotation does not match input_signature")
# Better
raise ValueError(f"Type annotation for argument '{arg}' expected {annotation_dtype} but input_signature specified {input_signature_dtype}")
Well-crafted error messages reduce debugging time and improve the overall developer experience when using your code.
Enter the URL of a public GitHub repository