Skip to content

Proposal: Gather exceptions and name them #1133

Description

@hinogi

Since there are quiet a lot of ValueError exceptions going on it would be a good way to gather them into their own module and give them meaningful names that make the code more readable and shows more intention.

if not keypoint_cat_ids:
        raise ValueError(
            "Keypoint COCO dataset has no keypoint category metadata and no keypoint annotations. "
            "Expected COCO categories with a 'keypoints' field or annotations with 'keypoints'/'num_keypoints'."
        )
    if len(keypoint_cat_ids) > len(active_slots):
        raise ValueError(
            "Keypoint COCO dataset has more keypoint-bearing categories "
            f"({len(keypoint_cat_ids)}) than active schema slots ({len(active_slots)}). "
            "Multi-class keypoint training needs an explicit num_keypoints_per_class schema."
        )

maybe this could be turned into some custom errors like

class MissingKeypointMetadataError(ValueError):
    pass

class TooManyKeypointCategoriesError(ValueError):
    pass

or even move the error messages into the class and extend the constructor to accept arguments for the output of the message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions