pinecone.openapi_support.exceptions
1class PineconeException(Exception): 2 """The base exception class for all exceptions in the Pinecone Python SDK""" 3 4 5class PineconeApiTypeError(PineconeException, TypeError): 6 def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None) -> None: 7 """Raises an exception for TypeErrors 8 9 Args: 10 msg (str): the exception message 11 12 Keyword Args: 13 path_to_item (list): a list of keys an indices to get to the 14 current_item 15 None if unset 16 valid_classes (tuple): the primitive classes that current item 17 should be an instance of 18 None if unset 19 key_type (bool): False if our value is a value in a dict 20 True if it is a key in a dict 21 False if our item is an item in a list 22 None if unset 23 """ 24 self.path_to_item = path_to_item 25 self.valid_classes = valid_classes 26 self.key_type = key_type 27 full_msg = msg 28 if path_to_item: 29 full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 30 super(PineconeApiTypeError, self).__init__(full_msg) 31 32 33class PineconeApiValueError(PineconeException, ValueError): 34 def __init__(self, msg, path_to_item=None) -> None: 35 """ 36 Args: 37 msg (str): the exception message 38 39 Keyword Args: 40 path_to_item (list) the path to the exception in the 41 received_data dict. None if unset 42 """ 43 44 self.path_to_item = path_to_item 45 full_msg = msg 46 if path_to_item: 47 full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 48 super(PineconeApiValueError, self).__init__(full_msg) 49 50 51class PineconeApiAttributeError(PineconeException, AttributeError): 52 def __init__(self, msg, path_to_item=None) -> None: 53 """ 54 Raised when an attribute reference or assignment fails. 55 56 Args: 57 msg (str): the exception message 58 59 Keyword Args: 60 path_to_item (None/list) the path to the exception in the 61 received_data dict 62 """ 63 self.path_to_item = path_to_item 64 full_msg = msg 65 if path_to_item: 66 full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 67 super(PineconeApiAttributeError, self).__init__(full_msg) 68 69 70class PineconeApiKeyError(PineconeException, KeyError): 71 def __init__(self, msg, path_to_item=None) -> None: 72 """ 73 Args: 74 msg (str): the exception message 75 76 Keyword Args: 77 path_to_item (None/list) the path to the exception in the 78 received_data dict 79 """ 80 self.path_to_item = path_to_item 81 full_msg = msg 82 if path_to_item: 83 full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 84 super(PineconeApiKeyError, self).__init__(full_msg) 85 86 87class PineconeApiException(PineconeException): 88 def __init__(self, status=None, reason=None, http_resp=None) -> None: 89 if http_resp: 90 self.status = http_resp.status 91 self.reason = http_resp.reason 92 self.body = http_resp.data 93 self.headers = http_resp.getheaders() 94 else: 95 self.status = status 96 self.reason = reason 97 self.body = None 98 self.headers = None 99 100 def __str__(self): 101 """Custom error messages for exception""" 102 error_message = "({0})\nReason: {1}\n".format(self.status, self.reason) 103 if self.headers: 104 error_message += "HTTP response headers: {0}\n".format(self.headers) 105 106 if self.body: 107 error_message += "HTTP response body: {0}\n".format(self.body) 108 109 return error_message 110 111 112class NotFoundException(PineconeApiException): 113 def __init__(self, status=None, reason=None, http_resp=None) -> None: 114 super(NotFoundException, self).__init__(status, reason, http_resp) 115 116 117class UnauthorizedException(PineconeApiException): 118 def __init__(self, status=None, reason=None, http_resp=None) -> None: 119 super(UnauthorizedException, self).__init__(status, reason, http_resp) 120 121 122class ForbiddenException(PineconeApiException): 123 def __init__(self, status=None, reason=None, http_resp=None) -> None: 124 super(ForbiddenException, self).__init__(status, reason, http_resp) 125 126 127class ServiceException(PineconeApiException): 128 def __init__(self, status=None, reason=None, http_resp=None) -> None: 129 super(ServiceException, self).__init__(status, reason, http_resp) 130 131 132def render_path(path_to_item): 133 """Returns a string representation of a path""" 134 result = "" 135 for pth in path_to_item: 136 if isinstance(pth, int): 137 result += "[{0}]".format(pth) 138 else: 139 result += "['{0}']".format(pth) 140 return result
2class PineconeException(Exception): 3 """The base exception class for all exceptions in the Pinecone Python SDK"""
The base exception class for all exceptions in the Pinecone Python SDK
Inherited Members
- builtins.Exception
- Exception
- builtins.BaseException
- with_traceback
- add_note
- args
6class PineconeApiTypeError(PineconeException, TypeError): 7 def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None) -> None: 8 """Raises an exception for TypeErrors 9 10 Args: 11 msg (str): the exception message 12 13 Keyword Args: 14 path_to_item (list): a list of keys an indices to get to the 15 current_item 16 None if unset 17 valid_classes (tuple): the primitive classes that current item 18 should be an instance of 19 None if unset 20 key_type (bool): False if our value is a value in a dict 21 True if it is a key in a dict 22 False if our item is an item in a list 23 None if unset 24 """ 25 self.path_to_item = path_to_item 26 self.valid_classes = valid_classes 27 self.key_type = key_type 28 full_msg = msg 29 if path_to_item: 30 full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 31 super(PineconeApiTypeError, self).__init__(full_msg)
The base exception class for all exceptions in the Pinecone Python SDK
7 def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None) -> None: 8 """Raises an exception for TypeErrors 9 10 Args: 11 msg (str): the exception message 12 13 Keyword Args: 14 path_to_item (list): a list of keys an indices to get to the 15 current_item 16 None if unset 17 valid_classes (tuple): the primitive classes that current item 18 should be an instance of 19 None if unset 20 key_type (bool): False if our value is a value in a dict 21 True if it is a key in a dict 22 False if our item is an item in a list 23 None if unset 24 """ 25 self.path_to_item = path_to_item 26 self.valid_classes = valid_classes 27 self.key_type = key_type 28 full_msg = msg 29 if path_to_item: 30 full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 31 super(PineconeApiTypeError, self).__init__(full_msg)
Raises an exception for TypeErrors
Arguments:
- msg (str): the exception message
Keyword Args:
path_to_item (list): a list of keys an indices to get to the current_item None if unset valid_classes (tuple): the primitive classes that current item should be an instance of None if unset key_type (bool): False if our value is a value in a dict True if it is a key in a dict False if our item is an item in a list None if unset
Inherited Members
- builtins.BaseException
- with_traceback
- add_note
- args
34class PineconeApiValueError(PineconeException, ValueError): 35 def __init__(self, msg, path_to_item=None) -> None: 36 """ 37 Args: 38 msg (str): the exception message 39 40 Keyword Args: 41 path_to_item (list) the path to the exception in the 42 received_data dict. None if unset 43 """ 44 45 self.path_to_item = path_to_item 46 full_msg = msg 47 if path_to_item: 48 full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 49 super(PineconeApiValueError, self).__init__(full_msg)
The base exception class for all exceptions in the Pinecone Python SDK
35 def __init__(self, msg, path_to_item=None) -> None: 36 """ 37 Args: 38 msg (str): the exception message 39 40 Keyword Args: 41 path_to_item (list) the path to the exception in the 42 received_data dict. None if unset 43 """ 44 45 self.path_to_item = path_to_item 46 full_msg = msg 47 if path_to_item: 48 full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 49 super(PineconeApiValueError, self).__init__(full_msg)
Arguments:
- msg (str): the exception message
Keyword Args:
path_to_item (list) the path to the exception in the received_data dict. None if unset
Inherited Members
- builtins.BaseException
- with_traceback
- add_note
- args
52class PineconeApiAttributeError(PineconeException, AttributeError): 53 def __init__(self, msg, path_to_item=None) -> None: 54 """ 55 Raised when an attribute reference or assignment fails. 56 57 Args: 58 msg (str): the exception message 59 60 Keyword Args: 61 path_to_item (None/list) the path to the exception in the 62 received_data dict 63 """ 64 self.path_to_item = path_to_item 65 full_msg = msg 66 if path_to_item: 67 full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 68 super(PineconeApiAttributeError, self).__init__(full_msg)
The base exception class for all exceptions in the Pinecone Python SDK
53 def __init__(self, msg, path_to_item=None) -> None: 54 """ 55 Raised when an attribute reference or assignment fails. 56 57 Args: 58 msg (str): the exception message 59 60 Keyword Args: 61 path_to_item (None/list) the path to the exception in the 62 received_data dict 63 """ 64 self.path_to_item = path_to_item 65 full_msg = msg 66 if path_to_item: 67 full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 68 super(PineconeApiAttributeError, self).__init__(full_msg)
Raised when an attribute reference or assignment fails.
Arguments:
- msg (str): the exception message
Keyword Args:
path_to_item (None/list) the path to the exception in the received_data dict
Inherited Members
- builtins.AttributeError
- name
- obj
- builtins.BaseException
- with_traceback
- add_note
- args
71class PineconeApiKeyError(PineconeException, KeyError): 72 def __init__(self, msg, path_to_item=None) -> None: 73 """ 74 Args: 75 msg (str): the exception message 76 77 Keyword Args: 78 path_to_item (None/list) the path to the exception in the 79 received_data dict 80 """ 81 self.path_to_item = path_to_item 82 full_msg = msg 83 if path_to_item: 84 full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 85 super(PineconeApiKeyError, self).__init__(full_msg)
The base exception class for all exceptions in the Pinecone Python SDK
72 def __init__(self, msg, path_to_item=None) -> None: 73 """ 74 Args: 75 msg (str): the exception message 76 77 Keyword Args: 78 path_to_item (None/list) the path to the exception in the 79 received_data dict 80 """ 81 self.path_to_item = path_to_item 82 full_msg = msg 83 if path_to_item: 84 full_msg = "{0} at {1}".format(msg, render_path(path_to_item)) 85 super(PineconeApiKeyError, self).__init__(full_msg)
Arguments:
- msg (str): the exception message
Keyword Args:
path_to_item (None/list) the path to the exception in the received_data dict
Inherited Members
- builtins.BaseException
- with_traceback
- add_note
- args
88class PineconeApiException(PineconeException): 89 def __init__(self, status=None, reason=None, http_resp=None) -> None: 90 if http_resp: 91 self.status = http_resp.status 92 self.reason = http_resp.reason 93 self.body = http_resp.data 94 self.headers = http_resp.getheaders() 95 else: 96 self.status = status 97 self.reason = reason 98 self.body = None 99 self.headers = None 100 101 def __str__(self): 102 """Custom error messages for exception""" 103 error_message = "({0})\nReason: {1}\n".format(self.status, self.reason) 104 if self.headers: 105 error_message += "HTTP response headers: {0}\n".format(self.headers) 106 107 if self.body: 108 error_message += "HTTP response body: {0}\n".format(self.body) 109 110 return error_message
The base exception class for all exceptions in the Pinecone Python SDK
89 def __init__(self, status=None, reason=None, http_resp=None) -> None: 90 if http_resp: 91 self.status = http_resp.status 92 self.reason = http_resp.reason 93 self.body = http_resp.data 94 self.headers = http_resp.getheaders() 95 else: 96 self.status = status 97 self.reason = reason 98 self.body = None 99 self.headers = None
Inherited Members
- builtins.BaseException
- with_traceback
- add_note
- args
113class NotFoundException(PineconeApiException): 114 def __init__(self, status=None, reason=None, http_resp=None) -> None: 115 super(NotFoundException, self).__init__(status, reason, http_resp)
The base exception class for all exceptions in the Pinecone Python SDK
Inherited Members
- builtins.BaseException
- with_traceback
- add_note
- args
123class ForbiddenException(PineconeApiException): 124 def __init__(self, status=None, reason=None, http_resp=None) -> None: 125 super(ForbiddenException, self).__init__(status, reason, http_resp)
The base exception class for all exceptions in the Pinecone Python SDK
Inherited Members
- builtins.BaseException
- with_traceback
- add_note
- args
128class ServiceException(PineconeApiException): 129 def __init__(self, status=None, reason=None, http_resp=None) -> None: 130 super(ServiceException, self).__init__(status, reason, http_resp)
The base exception class for all exceptions in the Pinecone Python SDK
Inherited Members
- builtins.BaseException
- with_traceback
- add_note
- args
133def render_path(path_to_item): 134 """Returns a string representation of a path""" 135 result = "" 136 for pth in path_to_item: 137 if isinstance(pth, int): 138 result += "[{0}]".format(pth) 139 else: 140 result += "['{0}']".format(pth) 141 return result
Returns a string representation of a path