pinecone.exceptions

 1from .core.exceptions import PineconeException, PineconeProtocolError
 2from .core.client.exceptions import (
 3    OpenApiException,
 4    ApiAttributeError,
 5    ApiTypeError,
 6    ApiValueError,
 7    ApiKeyError,
 8    ApiException,
 9    NotFoundException,
10    UnauthorizedException,
11    ForbiddenException,
12    ServiceException,
13)
14
15__all__ = [
16    "PineconeException",
17    "PineconeProtocolError",
18    "OpenApiException",
19    "ApiAttributeError",
20    "ApiTypeError",
21    "ApiValueError",
22    "ApiKeyError",
23    "ApiException",
24    "NotFoundException",
25    "UnauthorizedException",
26    "ForbiddenException",
27    "ServiceException",
28]
class PineconeException(builtins.Exception):
2class PineconeException(Exception):
3    """The base exception class for all Pinecone client exceptions."""

The base exception class for all Pinecone client exceptions.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class PineconeProtocolError(pinecone.exceptions.PineconeException):
6class PineconeProtocolError(PineconeException):
7    """Raised when something unexpected happens mid-request/response."""

Raised when something unexpected happens mid-request/response.

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class OpenApiException(pinecone.exceptions.PineconeException):
16class OpenApiException(PineconeException):
17    """The base exception class for all OpenAPIExceptions"""

The base exception class for all OpenAPIExceptions

Inherited Members
builtins.Exception
Exception
builtins.BaseException
with_traceback
add_note
args
class ApiAttributeError(pinecone.exceptions.OpenApiException, builtins.AttributeError):
66class ApiAttributeError(OpenApiException, AttributeError):
67    def __init__(self, msg, path_to_item=None):
68        """
69        Raised when an attribute reference or assignment fails.
70
71        Args:
72            msg (str): the exception message
73
74        Keyword Args:
75            path_to_item (None/list) the path to the exception in the
76                received_data dict
77        """
78        self.path_to_item = path_to_item
79        full_msg = msg
80        if path_to_item:
81            full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
82        super(ApiAttributeError, self).__init__(full_msg)

The base exception class for all OpenAPIExceptions

ApiAttributeError(msg, path_to_item=None)
67    def __init__(self, msg, path_to_item=None):
68        """
69        Raised when an attribute reference or assignment fails.
70
71        Args:
72            msg (str): the exception message
73
74        Keyword Args:
75            path_to_item (None/list) the path to the exception in the
76                received_data dict
77        """
78        self.path_to_item = path_to_item
79        full_msg = msg
80        if path_to_item:
81            full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
82        super(ApiAttributeError, 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

path_to_item
Inherited Members
builtins.AttributeError
name
obj
builtins.BaseException
with_traceback
add_note
args
class ApiTypeError(pinecone.exceptions.OpenApiException, builtins.TypeError):
20class ApiTypeError(OpenApiException, TypeError):
21    def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None):
22        """Raises an exception for TypeErrors
23
24        Args:
25            msg (str): the exception message
26
27        Keyword Args:
28            path_to_item (list): a list of keys an indices to get to the
29                                 current_item
30                                 None if unset
31            valid_classes (tuple): the primitive classes that current item
32                                   should be an instance of
33                                   None if unset
34            key_type (bool): False if our value is a value in a dict
35                             True if it is a key in a dict
36                             False if our item is an item in a list
37                             None if unset
38        """
39        self.path_to_item = path_to_item
40        self.valid_classes = valid_classes
41        self.key_type = key_type
42        full_msg = msg
43        if path_to_item:
44            full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
45        super(ApiTypeError, self).__init__(full_msg)

The base exception class for all OpenAPIExceptions

ApiTypeError(msg, path_to_item=None, valid_classes=None, key_type=None)
21    def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None):
22        """Raises an exception for TypeErrors
23
24        Args:
25            msg (str): the exception message
26
27        Keyword Args:
28            path_to_item (list): a list of keys an indices to get to the
29                                 current_item
30                                 None if unset
31            valid_classes (tuple): the primitive classes that current item
32                                   should be an instance of
33                                   None if unset
34            key_type (bool): False if our value is a value in a dict
35                             True if it is a key in a dict
36                             False if our item is an item in a list
37                             None if unset
38        """
39        self.path_to_item = path_to_item
40        self.valid_classes = valid_classes
41        self.key_type = key_type
42        full_msg = msg
43        if path_to_item:
44            full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
45        super(ApiTypeError, 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

path_to_item
valid_classes
key_type
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class ApiValueError(pinecone.exceptions.OpenApiException, builtins.ValueError):
48class ApiValueError(OpenApiException, ValueError):
49    def __init__(self, msg, path_to_item=None):
50        """
51        Args:
52            msg (str): the exception message
53
54        Keyword Args:
55            path_to_item (list) the path to the exception in the
56                received_data dict. None if unset
57        """
58
59        self.path_to_item = path_to_item
60        full_msg = msg
61        if path_to_item:
62            full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
63        super(ApiValueError, self).__init__(full_msg)

The base exception class for all OpenAPIExceptions

ApiValueError(msg, path_to_item=None)
49    def __init__(self, msg, path_to_item=None):
50        """
51        Args:
52            msg (str): the exception message
53
54        Keyword Args:
55            path_to_item (list) the path to the exception in the
56                received_data dict. None if unset
57        """
58
59        self.path_to_item = path_to_item
60        full_msg = msg
61        if path_to_item:
62            full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
63        super(ApiValueError, 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

path_to_item
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class ApiKeyError(pinecone.exceptions.OpenApiException, builtins.KeyError):
85class ApiKeyError(OpenApiException, KeyError):
86    def __init__(self, msg, path_to_item=None):
87        """
88        Args:
89            msg (str): the exception message
90
91        Keyword Args:
92            path_to_item (None/list) the path to the exception in the
93                received_data dict
94        """
95        self.path_to_item = path_to_item
96        full_msg = msg
97        if path_to_item:
98            full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
99        super(ApiKeyError, self).__init__(full_msg)

The base exception class for all OpenAPIExceptions

ApiKeyError(msg, path_to_item=None)
86    def __init__(self, msg, path_to_item=None):
87        """
88        Args:
89            msg (str): the exception message
90
91        Keyword Args:
92            path_to_item (None/list) the path to the exception in the
93                received_data dict
94        """
95        self.path_to_item = path_to_item
96        full_msg = msg
97        if path_to_item:
98            full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
99        super(ApiKeyError, 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

path_to_item
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class ApiException(pinecone.exceptions.OpenApiException):
102class ApiException(OpenApiException):
103    def __init__(self, status=None, reason=None, http_resp=None):
104        if http_resp:
105            self.status = http_resp.status
106            self.reason = http_resp.reason
107            self.body = http_resp.data
108            self.headers = http_resp.getheaders()
109        else:
110            self.status = status
111            self.reason = reason
112            self.body = None
113            self.headers = None
114
115    def __str__(self):
116        """Custom error messages for exception"""
117        error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason)
118        if self.headers:
119            error_message += "HTTP response headers: {0}\n".format(self.headers)
120
121        if self.body:
122            error_message += "HTTP response body: {0}\n".format(self.body)
123
124        return error_message

The base exception class for all OpenAPIExceptions

ApiException(status=None, reason=None, http_resp=None)
103    def __init__(self, status=None, reason=None, http_resp=None):
104        if http_resp:
105            self.status = http_resp.status
106            self.reason = http_resp.reason
107            self.body = http_resp.data
108            self.headers = http_resp.getheaders()
109        else:
110            self.status = status
111            self.reason = reason
112            self.body = None
113            self.headers = None
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class NotFoundException(pinecone.exceptions.ApiException):
127class NotFoundException(ApiException):
128    def __init__(self, status=None, reason=None, http_resp=None):
129        super(NotFoundException, self).__init__(status, reason, http_resp)

The base exception class for all OpenAPIExceptions

NotFoundException(status=None, reason=None, http_resp=None)
128    def __init__(self, status=None, reason=None, http_resp=None):
129        super(NotFoundException, self).__init__(status, reason, http_resp)
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class UnauthorizedException(pinecone.exceptions.ApiException):
132class UnauthorizedException(ApiException):
133    def __init__(self, status=None, reason=None, http_resp=None):
134        super(UnauthorizedException, self).__init__(status, reason, http_resp)

The base exception class for all OpenAPIExceptions

UnauthorizedException(status=None, reason=None, http_resp=None)
133    def __init__(self, status=None, reason=None, http_resp=None):
134        super(UnauthorizedException, self).__init__(status, reason, http_resp)
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class ForbiddenException(pinecone.exceptions.ApiException):
137class ForbiddenException(ApiException):
138    def __init__(self, status=None, reason=None, http_resp=None):
139        super(ForbiddenException, self).__init__(status, reason, http_resp)

The base exception class for all OpenAPIExceptions

ForbiddenException(status=None, reason=None, http_resp=None)
138    def __init__(self, status=None, reason=None, http_resp=None):
139        super(ForbiddenException, self).__init__(status, reason, http_resp)
Inherited Members
builtins.BaseException
with_traceback
add_note
args
class ServiceException(pinecone.exceptions.ApiException):
142class ServiceException(ApiException):
143    def __init__(self, status=None, reason=None, http_resp=None):
144        super(ServiceException, self).__init__(status, reason, http_resp)

The base exception class for all OpenAPIExceptions

ServiceException(status=None, reason=None, http_resp=None)
143    def __init__(self, status=None, reason=None, http_resp=None):
144        super(ServiceException, self).__init__(status, reason, http_resp)
Inherited Members
builtins.BaseException
with_traceback
add_note
args