Skip to content

errors

AbstractNylasApiError

Bases: Exception

Base class for all Nylas API errors.

Attributes:

Name Type Description
request_id str

The unique identifier of the request.

status_code int

The HTTP status code of the error response.

Source code in nylas/models/errors.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class AbstractNylasApiError(Exception):
    """
    Base class for all Nylas API errors.

    Attributes:
        request_id: The unique identifier of the request.
        status_code: The HTTP status code of the error response.
    """

    def __init__(
        self,
        message: str,
        request_id: Optional[str] = None,
        status_code: Optional[int] = None,
    ):
        """
        Args:
            request_id: The unique identifier of the request.
            status_code: The HTTP status code of the error response.
            message: The error message.
        """
        self.request_id: str = request_id
        self.status_code: int = status_code
        super().__init__(message)

__init__(message, request_id=None, status_code=None)

Parameters:

Name Type Description Default
request_id Optional[str]

The unique identifier of the request.

None
status_code Optional[int]

The HTTP status code of the error response.

None
message str

The error message.

required
Source code in nylas/models/errors.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def __init__(
    self,
    message: str,
    request_id: Optional[str] = None,
    status_code: Optional[int] = None,
):
    """
    Args:
        request_id: The unique identifier of the request.
        status_code: The HTTP status code of the error response.
        message: The error message.
    """
    self.request_id: str = request_id
    self.status_code: int = status_code
    super().__init__(message)

AbstractNylasSdkError

Bases: Exception

Base class for all Nylas SDK errors.

Source code in nylas/models/errors.py
33
34
35
36
37
38
class AbstractNylasSdkError(Exception):
    """
    Base class for all Nylas SDK errors.
    """

    pass

NylasApiError

Bases: AbstractNylasApiError

Class representation of a general Nylas API error.

Attributes:

Name Type Description
type str

Error type.

provider_error Optional[dict]

Provider Error.

Source code in nylas/models/errors.py
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
class NylasApiError(AbstractNylasApiError):
    """
    Class representation of a general Nylas API error.

    Attributes:
        type: Error type.
        provider_error: Provider Error.
    """

    def __init__(
        self,
        api_error: NylasApiErrorResponse,
        status_code: Optional[int] = None,
    ):
        """
        Args:
            api_error: The error details from the API.
            status_code: The HTTP status code of the error response.
        """
        super().__init__(api_error.error.message, api_error.request_id, status_code)
        self.type: str = api_error.error.type
        self.provider_error: Optional[dict] = api_error.error.provider_error

__init__(api_error, status_code=None)

Parameters:

Name Type Description Default
api_error NylasApiErrorResponse

The error details from the API.

required
status_code Optional[int]

The HTTP status code of the error response.

None
Source code in nylas/models/errors.py
101
102
103
104
105
106
107
108
109
110
111
112
113
def __init__(
    self,
    api_error: NylasApiErrorResponse,
    status_code: Optional[int] = None,
):
    """
    Args:
        api_error: The error details from the API.
        status_code: The HTTP status code of the error response.
    """
    super().__init__(api_error.error.message, api_error.request_id, status_code)
    self.type: str = api_error.error.type
    self.provider_error: Optional[dict] = api_error.error.provider_error

NylasApiErrorResponse dataclass

Interface representing the error response from the Nylas API.

Attributes:

Name Type Description
request_id str

The unique identifier of the request.

error NylasApiErrorResponseData

The error data.

Source code in nylas/models/errors.py
58
59
60
61
62
63
64
65
66
67
68
69
70
@dataclass_json
@dataclass
class NylasApiErrorResponse:
    """
    Interface representing the error response from the Nylas API.

    Attributes:
        request_id: The unique identifier of the request.
        error: The error data.
    """

    request_id: str
    error: NylasApiErrorResponseData

NylasApiErrorResponseData dataclass

Interface representing the error data within the response object.

Attributes:

Name Type Description
type str

The type of error.

message str

The error message.

provider_error Optional[dict]

The provider error if there is one.

Source code in nylas/models/errors.py
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@dataclass_json
@dataclass
class NylasApiErrorResponseData:
    """
    Interface representing the error data within the response object.

    Attributes:
        type: The type of error.
        message: The error message.
        provider_error: The provider error if there is one.
    """

    type: str
    message: str
    provider_error: Optional[dict] = None

NylasOAuthError

Bases: AbstractNylasApiError

Class representation of an OAuth error returned by the Nylas API.

Attributes:

Name Type Description
error str

Error type.

error_code int

Error code used for referencing the docs, logs, and data stream.

error_description str

Human readable error description.

error_uri str

URL to the related documentation and troubleshooting regarding this error.

Source code in nylas/models/errors.py
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
class NylasOAuthError(AbstractNylasApiError):
    """
    Class representation of an OAuth error returned by the Nylas API.

    Attributes:
        error: Error type.
        error_code: Error code used for referencing the docs, logs, and data stream.
        error_description: Human readable error description.
        error_uri: URL to the related documentation and troubleshooting regarding this error.
    """

    def __init__(
        self,
        oauth_error: NylasOAuthErrorResponse,
        status_code: Optional[int] = None,
    ):
        """
        Args:
            oauth_error: The error details from the API.
            status_code: The HTTP status code of the error response.
        """
        super().__init__(oauth_error.error_description, status_code)
        self.error: str = oauth_error.error
        self.error_code: int = oauth_error.error_code
        self.error_description: str = oauth_error.error_description
        self.error_uri: str = oauth_error.error_uri

__init__(oauth_error, status_code=None)

Parameters:

Name Type Description Default
oauth_error NylasOAuthErrorResponse

The error details from the API.

required
status_code Optional[int]

The HTTP status code of the error response.

None
Source code in nylas/models/errors.py
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
def __init__(
    self,
    oauth_error: NylasOAuthErrorResponse,
    status_code: Optional[int] = None,
):
    """
    Args:
        oauth_error: The error details from the API.
        status_code: The HTTP status code of the error response.
    """
    super().__init__(oauth_error.error_description, status_code)
    self.error: str = oauth_error.error
    self.error_code: int = oauth_error.error_code
    self.error_description: str = oauth_error.error_description
    self.error_uri: str = oauth_error.error_uri

NylasOAuthErrorResponse dataclass

Interface representing an OAuth error returned by the Nylas API.

Attributes:

Name Type Description
error str

Error type.

error_code int

Error code used for referencing the docs, logs, and data stream.

error_description str

Human readable error description.

error_uri str

URL to the related documentation and troubleshooting regarding this error.

Source code in nylas/models/errors.py
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
@dataclass_json
@dataclass
class NylasOAuthErrorResponse:
    """
    Interface representing an OAuth error returned by the Nylas API.

    Attributes:
        error: Error type.
        error_code: Error code used for referencing the docs, logs, and data stream.
        error_description: Human readable error description.
        error_uri: URL to the related documentation and troubleshooting regarding this error.
    """

    error: str
    error_code: int
    error_description: str
    error_uri: str

NylasSdkTimeoutError

Bases: AbstractNylasSdkError

Error thrown when the Nylas SDK times out before receiving a response from the server.

Attributes:

Name Type Description
url str

The URL that timed out.

timeout int

The timeout value set in the Nylas SDK, in seconds.

Source code in nylas/models/errors.py
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
class NylasSdkTimeoutError(AbstractNylasSdkError):
    """
    Error thrown when the Nylas SDK times out before receiving a response from the server.

    Attributes:
        url: The URL that timed out.
        timeout: The timeout value set in the Nylas SDK, in seconds.
    """

    def __init__(self, url: str, timeout: int):
        """
        Args:
            url: The URL that timed out.
            timeout: The timeout value set in the Nylas SDK, in seconds.
        """
        super().__init__(
            "Nylas SDK timed out before receiving a response from the server."
        )
        self.url: str = url
        self.timeout: int = timeout

__init__(url, timeout)

Parameters:

Name Type Description Default
url str

The URL that timed out.

required
timeout int

The timeout value set in the Nylas SDK, in seconds.

required
Source code in nylas/models/errors.py
153
154
155
156
157
158
159
160
161
162
163
def __init__(self, url: str, timeout: int):
    """
    Args:
        url: The URL that timed out.
        timeout: The timeout value set in the Nylas SDK, in seconds.
    """
    super().__init__(
        "Nylas SDK timed out before receiving a response from the server."
    )
    self.url: str = url
    self.timeout: int = timeout