-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathexceptions.py
More file actions
72 lines (48 loc) · 1.9 KB
/
exceptions.py
File metadata and controls
72 lines (48 loc) · 1.9 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""Custom exceptions for Supermemory ADK integration."""
from typing import Optional
class SupermemoryADKError(Exception):
"""Base exception for all Supermemory ADK errors."""
def __init__(self, message: str, original_error: Optional[Exception] = None):
super().__init__(message)
self.message = message
self.original_error = original_error
def __str__(self) -> str:
if self.original_error:
return f"{self.message}: {self.original_error}"
return self.message
class SupermemoryConfigurationError(SupermemoryADKError):
"""Raised when there are configuration issues (e.g., missing API key, invalid params)."""
pass
class SupermemoryAPIError(SupermemoryADKError):
"""Raised when Supermemory API requests fail."""
def __init__(
self,
message: str,
status_code: Optional[int] = None,
response_text: Optional[str] = None,
original_error: Optional[Exception] = None,
):
super().__init__(message, original_error)
self.status_code = status_code
self.response_text = response_text
def __str__(self) -> str:
parts = [self.message]
if self.status_code:
parts.append(f"Status: {self.status_code}")
if self.response_text:
parts.append(f"Response: {self.response_text}")
if self.original_error:
parts.append(f"Cause: {self.original_error}")
return " | ".join(parts)
class SupermemoryMemoryOperationError(SupermemoryADKError):
"""Raised when memory operations (search, add) fail."""
pass
class SupermemoryTimeoutError(SupermemoryADKError):
"""Raised when operations timeout."""
pass
class SupermemoryNetworkError(SupermemoryADKError):
"""Raised when network operations fail."""
pass
class SupermemoryToolError(SupermemoryADKError):
"""Raised when ADK tool execution fails."""
pass