/ src / evidently / legacy / ui / errors.py
errors.py
 1  from abc import abstractmethod
 2  
 3  from litestar import Response
 4  
 5  from evidently.errors import EvidentlyError
 6  
 7  
 8  class EvidentlyServiceError(EvidentlyError):
 9      @abstractmethod
10      def to_response(self) -> Response:
11          raise NotImplementedError
12  
13  
14  class EntityNotFound(EvidentlyServiceError):
15      entity_name: str = ""
16  
17      def to_response(self) -> Response:
18          return Response(
19              status_code=404,
20              content={"detail": f"{self.entity_name} not found"},
21          )
22  
23  
24  class ProjectNotFound(EntityNotFound):
25      entity_name = "Project"
26  
27  
28  class OrgNotFound(EntityNotFound):
29      entity_name = "Org"
30  
31  
32  class TeamNotFound(EntityNotFound):
33      entity_name = "Team"
34  
35  
36  class UserNotFound(EntityNotFound):
37      entity_name = "User"
38  
39  
40  class RoleNotFound(EntityNotFound):
41      entity_name = "Role"
42  
43  
44  class SnapshotNotFound(EntityNotFound):
45      entity_name = "Snapshot"
46  
47  
48  class NotEnoughPermissions(EvidentlyServiceError):
49      def to_response(self) -> Response:
50          return Response(
51              status_code=403,
52              content={"detail": "Not enough permissions"},
53          )
54  
55  
56  class NotAuthorized(EvidentlyServiceError):
57      def to_response(self) -> Response:
58          return Response(
59              status_code=401,
60              content={"detail": "Not authorized"},
61          )