forked from a2aproject/a2a-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.py
More file actions
71 lines (59 loc) · 2.08 KB
/
Copy patherrors.py
File metadata and controls
71 lines (59 loc) · 2.08 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
"""Custom exceptions for A2A server-side errors."""
from a2a.types import (
AuthenticatedExtendedCardNotConfiguredError,
ContentTypeNotSupportedError,
InternalError,
InvalidAgentResponseError,
InvalidParamsError,
InvalidRequestError,
JSONParseError,
JSONRPCError,
MethodNotFoundError,
PushNotificationNotSupportedError,
TaskNotCancelableError,
TaskNotFoundError,
UnsupportedOperationError,
)
class A2AServerError(Exception):
"""Base exception for A2A Server errors."""
class MethodNotImplementedError(A2AServerError):
"""Exception raised for methods that are not implemented by the server handler."""
def __init__(
self, message: str = 'This method is not implemented by the server'
):
"""Initializes the MethodNotImplementedError.
Args:
message: A descriptive error message.
"""
self.message = message
super().__init__(f'Not Implemented operation Error: {message}')
class ServerError(Exception):
"""Wrapper exception for A2A or JSON-RPC errors originating from the server's logic.
This exception is used internally by request handlers and other server components
to signal a specific error that should be formatted as a JSON-RPC error response.
"""
def __init__(
self,
error: (
JSONRPCError
| JSONParseError
| InvalidRequestError
| MethodNotFoundError
| InvalidParamsError
| InternalError
| TaskNotFoundError
| TaskNotCancelableError
| PushNotificationNotSupportedError
| UnsupportedOperationError
| ContentTypeNotSupportedError
| InvalidAgentResponseError
| AuthenticatedExtendedCardNotConfiguredError
| None
),
):
"""Initializes the ServerError.
Args:
error: The specific A2A or JSON-RPC error model instance.
If None, an `InternalError` will be used when formatting the response.
"""
self.error = error