src/pqc_federated_learning/errors.py
850 B · 32 lines · python Raw
1 """Exception hierarchy for pqc-federated-learning."""
2
3 from __future__ import annotations
4
5
6 class FLError(Exception):
7 """Base exception for all pqc-federated-learning errors."""
8
9
10 class InvalidUpdateError(FLError):
11 """Raised when a client update is structurally invalid."""
12
13
14 class SignatureVerificationError(FLError):
15 """Raised when a client update's signature fails to verify."""
16
17
18 class AggregationError(FLError):
19 """Raised when aggregation cannot proceed (e.g., round/model mismatch)."""
20
21
22 class UntrustedClientError(FLError):
23 """Raised when a client update is signed by a DID not in the trusted set."""
24
25
26 class ShapeMismatchError(FLError):
27 """Raised when client tensors disagree on names or shapes."""
28
29
30 class InsufficientUpdatesError(FLError):
31 """Raised when fewer than `min_updates` valid updates are available."""
32