Skip to content

An invalid ttl raises CacheXError in @cache but TypeError/ValueError in backends and CacheManager #337

Description

@allen0099

Problem

An invalid ttl raises different exception types depending on where it is passed:

  • @cache(ttl=...) raises CacheXError;
  • backends and CacheManager (validate_ttl) raise TypeError or ValueError.

Code that validates user-supplied TTLs has to catch all three.

Proposal

Pick one convention. For example, a CacheXError subclass that also inherits from TypeError / ValueError, so existing except clauses keep working. Document it in the API reference.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    developer-experienceSurprising behaviour, missing warnings or unclear errors for library usersenhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions