utils/freedays/freedays/_errors.py
Krzysztof kuhy Rudnicki c490ba5992 freedays 0.4.0: mark refuses a sick day (call-time sickdays import, allow+warn if absent)
Also fixes a ~5% flake in the hmac round-trip test (freedays and sickdays):
load_key strips whitespace, so a random key edged with a whitespace byte
never compared equal to the raw bytes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xfj1sxKH9VBPqpcAni8Jry
2026-10-16 08:28:44 +02:00

40 lines
1.1 KiB
Python

# Copyright (c) 2026 Krzysztof Rudnicki
"""Why a mark or un-mark was refused.
Each of these is a *policy* refusal with a message meant to be shown to the
person who typed the command. None of them indicates a bug, so callers are
expected to catch them and print ``str(exc)`` rather than let a traceback
out.
"""
from __future__ import annotations
class FreeDayError(Exception):
"""Base class for every policy refusal in this package."""
class PastDateError(FreeDayError):
"""A day in the past cannot be marked free.
This is the one real abuse vector in an otherwise frictionless system:
without it, a gate that already fired and was already failed could be
erased after the fact.
"""
class BudgetExhaustedError(FreeDayError):
"""This calendar year has no free days left."""
class AlreadyFreeError(FreeDayError):
"""The day is already marked free, so marking it again would be a no-op."""
class NotFreeError(FreeDayError):
"""The day is not marked free, so there is nothing to release."""
class SickDayConflictError(FreeDayError):
"""The day is a sick day (``sickdays``); a date is never in both pools."""