cleverly.exceptions.Refusal#

class cleverly.exceptions.Refusal(reason: RefusalReason, condition: str, alternative: str | None = None, roadmap: str | None = None)[source]#

One refusal: its reason code, the failed condition, and what to do instead.

Parameters:
reasonRefusalReason

Where the problem is.

conditionstr

The sentences that state the failed condition. They end with a full stop. A condition that a raise splices into a longer message can open with a lowercase word.

alternativestr or None

The sentence that names a working call, or NO_ALTERNATIVE. Required for every code except RefusalReason.INVALID_DECLARATION.

roadmapstr or None

The id of the docs/roadmap.md item that tracks a missing capability, such as "F21". An RefusalReason.IMPLEMENTATION_GAP refusal always names one.

Raises:
TypeError

When reason is not a RefusalReason, when condition is empty, or when a code that needs an alternative has none.

Methods#

Refusal.message() → str[source]#

The text a raise prints and a capability row quotes.

Returns:
str

condition, then a sentence that names roadmap when the condition does not already name it, then alternative.

Attributes#

Refusal.alternative: str | None = None#
Refusal.roadmap: str | None = None#
Refusal.reason: RefusalReason#
Refusal.condition: str#