Coverage for app / common / exceptions.py: 100%

25 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-10-31 11:21 +0000

1from fastapi.exceptions import HTTPException 

2from fastapi import status 

3 

4# Auth 

5 

6TokenExpiredException = HTTPException( 

7 status_code=status.HTTP_401_UNAUTHORIZED, 

8 detail="Token has expired", 

9) 

10 

11TokenInvalidAudienceException = HTTPException( 

12 status_code=status.HTTP_401_UNAUTHORIZED, 

13 detail="Invalid token audience", 

14) 

15 

16TokenInvalidIssuerException = HTTPException( 

17 status_code=status.HTTP_401_UNAUTHORIZED, 

18 detail="Invalid token issuer", 

19) 

20 

21TokenInvalidSignatureException = HTTPException( 

22 status_code=status.HTTP_401_UNAUTHORIZED, 

23 detail="Invalid token signature", 

24) 

25 

26TokenInvalidException = HTTPException( 

27 status_code=status.HTTP_401_UNAUTHORIZED, 

28 detail="Invalid authentication credentials", 

29) 

30 

31# User 

32 

33UserNotProvisionedException = HTTPException( 

34 status_code=status.HTTP_403_FORBIDDEN, 

35 detail="User is not provisioned in this system", 

36) 

37 

38UserDisabledException = HTTPException( 

39 status_code=status.HTTP_403_FORBIDDEN, 

40 detail="User account is disabled", 

41) 

42 

43UserNotFoundException = HTTPException( 

44 status_code=status.HTTP_404_NOT_FOUND, 

45 detail="User not found", 

46) 

47 

48UserFailedToCreateException = HTTPException( 

49 status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, 

50 detail="Failed to create user", 

51) 

52 

53# Org 

54 

55OrgContextInvalidException = HTTPException( 

56 status_code=status.HTTP_400_BAD_REQUEST, 

57 detail="Organisation context not provided", 

58) 

59 

60OrgUserInvalidException = HTTPException( 

61 status_code=status.HTTP_403_FORBIDDEN, 

62 detail="User does not belong to this organisation", 

63) 

64 

65OrganisationNotFoundException = HTTPException( 

66 status_code=status.HTTP_404_NOT_FOUND, 

67 detail="Organisation not found", 

68) 

69 

70OrganisationFailedToCreateException = HTTPException( 

71 status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, 

72 detail="Failed to create organisation", 

73) 

74 

75# Models 

76 

77ModelNotFoundException = HTTPException( 

78 status_code=status.HTTP_404_NOT_FOUND, detail="Model not found" 

79) 

80 

81ModelUnavailableException = HTTPException( 

82 status_code=status.HTTP_503_SERVICE_UNAVAILABLE, 

83 detail="Model unavailable - source configuration missing", 

84) 

85 

86# Agents 

87 

88AgentNotFoundException = HTTPException( 

89 status_code=status.HTTP_404_NOT_FOUND, detail="Agent not found" 

90) 

91 

92# Conversations 

93 

94ConversationNotFoundException = HTTPException( 

95 status_code=status.HTTP_404_NOT_FOUND, detail="Conversation not found" 

96) 

97 

98ConversationInvalidArgumentsException = HTTPException( 

99 status_code=status.HTTP_400_BAD_REQUEST, 

100 detail="Error - invalid arguments were provided when trying to fetch conversation", 

101) 

102 

103# Knowledge 

104 

105KnowledgeNotFoundException = HTTPException( 

106 status_code=status.HTTP_404_NOT_FOUND, detail="Knowledge not found" 

107) 

108 

109# Projects 

110 

111ProjectNotFoundException = HTTPException( 

112 status_code=status.HTTP_404_NOT_FOUND, 

113 detail="Project not found", 

114) 

115 

116ProjectFailedToCreateException = HTTPException( 

117 status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, 

118 detail="Failed to create project", 

119) 

120 

121# Tasks 

122 

123TaskNotFoundException = HTTPException( 

124 status_code=status.HTTP_404_NOT_FOUND, 

125 detail="Task not found", 

126) 

127 

128# Permissions 

129 

130InsufficientPermissionsException = HTTPException( 

131 status_code=status.HTTP_403_FORBIDDEN, 

132 detail="Insufficient permissions", 

133)