Plain is headed towards 1.0! Subscribe for development updates →

 1from __future__ import annotations
 2
 3from typing import Any
 4
 5from plain.models.db import DatabaseError
 6
 7
 8class AmbiguityError(Exception):
 9    """More than one migration matches a name prefix."""
10
11    pass
12
13
14class BadMigrationError(Exception):
15    """There's a bad migration (unreadable/bad format/etc.)."""
16
17    pass
18
19
20class CircularDependencyError(Exception):
21    """There's an impossible-to-resolve circular dependency."""
22
23    pass
24
25
26class InconsistentMigrationHistory(Exception):
27    """An applied migration has some of its dependencies not applied."""
28
29    pass
30
31
32class InvalidBasesError(ValueError):
33    """A model's base classes can't be resolved."""
34
35    pass
36
37
38class NodeNotFoundError(LookupError):
39    """An attempt on a node is made that is not available in the graph."""
40
41    def __init__(self, message: str, node: Any, origin: Any = None) -> None:
42        self.message = message
43        self.origin = origin
44        self.node = node
45
46    def __str__(self) -> str:
47        return self.message
48
49    def __repr__(self) -> str:
50        return f"NodeNotFoundError({self.node!r})"
51
52
53class MigrationSchemaMissing(DatabaseError):
54    pass