forked from Zipstack/unstract
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexceptions.py
More file actions
46 lines (31 loc) · 1.19 KB
/
exceptions.py
File metadata and controls
46 lines (31 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from typing import Optional
from rest_framework.exceptions import APIException
class ToolInstanceBaseException(APIException):
def __init__(
self,
detail: Optional[str] = None,
code: Optional[int] = None,
tool_name: Optional[str] = None,
) -> None:
detail = detail or self.default_detail
if tool_name is not None:
detail = f"{detail} Tool: {tool_name}"
super().__init__(detail, code)
class ToolFunctionIsMandatory(ToolInstanceBaseException):
status_code = 400
default_detail = "Tool function is mandatory."
class ToolDoesNotExist(ToolInstanceBaseException):
status_code = 400
default_detail = "Tool doesn't exist."
class FetchToolListFailed(ToolInstanceBaseException):
status_code = 400
default_detail = "Failed to fetch tool list."
class ToolInstantiationError(ToolInstanceBaseException):
status_code = 500
default_detail = "Error instantiating tool."
class BadRequestException(ToolInstanceBaseException):
status_code = 400
default_detail = "Invalid input."
class ToolSettingValidationError(APIException):
status_code = 400
default_detail = "Error while validating tool's setting."