Skip to content

Use locally defined exception classes instead of raising generic exception types. #8

Closed
@Ferroin

Description

@Ferroin

Prompted by: netdata/netdata#7024

This module appears to directly raise ValueError and RuntimeError under specific circumstances. While both are technically accurate, they necessitate use of overly broad except clauses when dealing with error handling for the module, which makes it difficult to verify that code using the module is actually correct and can't accidentally hide other errors. The RuntimeError usage is particularly problematic, as it's very rare in the core language to ever catch a RuntimeError, so any code that catches one tends to look rather out of place to many people.

I would suggest switching to the same methodology that's used by much of the Python ecosystem of defining local sub-classes of Exception (or whatever specific error makes sense) and raising those instead of directly raising built-in exception types.

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