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
« 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
4# Auth
6TokenExpiredException = HTTPException(
7 status_code=status.HTTP_401_UNAUTHORIZED,
8 detail="Token has expired",
9)
11TokenInvalidAudienceException = HTTPException(
12 status_code=status.HTTP_401_UNAUTHORIZED,
13 detail="Invalid token audience",
14)
16TokenInvalidIssuerException = HTTPException(
17 status_code=status.HTTP_401_UNAUTHORIZED,
18 detail="Invalid token issuer",
19)
21TokenInvalidSignatureException = HTTPException(
22 status_code=status.HTTP_401_UNAUTHORIZED,
23 detail="Invalid token signature",
24)
26TokenInvalidException = HTTPException(
27 status_code=status.HTTP_401_UNAUTHORIZED,
28 detail="Invalid authentication credentials",
29)
31# User
33UserNotProvisionedException = HTTPException(
34 status_code=status.HTTP_403_FORBIDDEN,
35 detail="User is not provisioned in this system",
36)
38UserDisabledException = HTTPException(
39 status_code=status.HTTP_403_FORBIDDEN,
40 detail="User account is disabled",
41)
43UserNotFoundException = HTTPException(
44 status_code=status.HTTP_404_NOT_FOUND,
45 detail="User not found",
46)
48UserFailedToCreateException = HTTPException(
49 status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
50 detail="Failed to create user",
51)
53# Org
55OrgContextInvalidException = HTTPException(
56 status_code=status.HTTP_400_BAD_REQUEST,
57 detail="Organisation context not provided",
58)
60OrgUserInvalidException = HTTPException(
61 status_code=status.HTTP_403_FORBIDDEN,
62 detail="User does not belong to this organisation",
63)
65OrganisationNotFoundException = HTTPException(
66 status_code=status.HTTP_404_NOT_FOUND,
67 detail="Organisation not found",
68)
70OrganisationFailedToCreateException = HTTPException(
71 status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
72 detail="Failed to create organisation",
73)
75# Models
77ModelNotFoundException = HTTPException(
78 status_code=status.HTTP_404_NOT_FOUND, detail="Model not found"
79)
81ModelUnavailableException = HTTPException(
82 status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
83 detail="Model unavailable - source configuration missing",
84)
86# Agents
88AgentNotFoundException = HTTPException(
89 status_code=status.HTTP_404_NOT_FOUND, detail="Agent not found"
90)
92# Conversations
94ConversationNotFoundException = HTTPException(
95 status_code=status.HTTP_404_NOT_FOUND, detail="Conversation not found"
96)
98ConversationInvalidArgumentsException = HTTPException(
99 status_code=status.HTTP_400_BAD_REQUEST,
100 detail="Error - invalid arguments were provided when trying to fetch conversation",
101)
103# Knowledge
105KnowledgeNotFoundException = HTTPException(
106 status_code=status.HTTP_404_NOT_FOUND, detail="Knowledge not found"
107)
109# Projects
111ProjectNotFoundException = HTTPException(
112 status_code=status.HTTP_404_NOT_FOUND,
113 detail="Project not found",
114)
116ProjectFailedToCreateException = HTTPException(
117 status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
118 detail="Failed to create project",
119)
121# Tasks
123TaskNotFoundException = HTTPException(
124 status_code=status.HTTP_404_NOT_FOUND,
125 detail="Task not found",
126)
128# Permissions
130InsufficientPermissionsException = HTTPException(
131 status_code=status.HTTP_403_FORBIDDEN,
132 detail="Insufficient permissions",
133)