Skip to content

errors

AbstractNylasApiError

Bases: Exception

Base class for all Nylas API errors.

Attributes:

Name Type Description
request_id Optional[str]

The unique identifier of the request.

status_code Optional[int]

The HTTP status code of the error response.

headers Optional[CaseInsensitiveDict]

The headers returned from the API.

Source code in nylas/models/errors.py
 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
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.
        headers: The headers returned from the API.
    """

    def __init__(
        self,
        message: str,
        request_id: Optional[str] = None,
        status_code: Optional[int] = None,
        headers: Optional[CaseInsensitiveDict] = 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: Optional[str] = request_id
        self.status_code: Optional[int] = status_code
        self.headers: Optional[CaseInsensitiveDict] = headers
        super().__init__(message)

__init__(message, request_id=None, status_code=None, headers=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
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def __init__(
    self,
    message: str,
    request_id: Optional[str] = None,
    status_code: Optional[int] = None,
    headers: Optional[CaseInsensitiveDict] = 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: Optional[str] = request_id
    self.status_code: Optional[int] = status_code
    self.headers: Optional[CaseInsensitiveDict] = headers
    super().__init__(message)

AbstractNylasSdkError

Bases: Exception

Base class for all Nylas SDK errors.

Source code in nylas/models/errors.py
37
38
39
40
41
42
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.

headers CaseInsensitiveDict

The headers returned from the API.

Source code in nylas/models/errors.py
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
class NylasApiError(AbstractNylasApiError):
    """
    Class representation of a general Nylas API error.

    Attributes:
        type: Error type.
        provider_error: Provider Error.
        headers: The headers returned from the API.
    """

    def __init__(
        self,
        api_error: NylasApiErrorResponse,
        status_code: Optional[int] = None,
        headers: Optional[CaseInsensitiveDict] = 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, headers)
        self.type: str = api_error.error.type
        self.provider_error: Optional[dict] = api_error.error.provider_error
        self.headers: CaseInsensitiveDict = headers

__init__(api_error, status_code=None, headers=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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
def __init__(
    self,
    api_error: NylasApiErrorResponse,
    status_code: Optional[int] = None,
    headers: Optional[CaseInsensitiveDict] = 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, headers)
    self.type: str = api_error.error.type
    self.provider_error: Optional[dict] = api_error.error.provider_error
    self.headers: CaseInsensitiveDict = headers

NylasApiErrorResponse dataclass

Interface representing the error response from the Nylas API.

Attributes:

Name Type Description
request_id Optional[str]

The unique identifier of the request.

error NylasApiErrorResponseData

The error data.

Source code in nylas/models/errors.py
62
63
64
65
66
67
68
69
70
71
72
73
74
@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: Optional[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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
@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

NylasNetworkError

Bases: AbstractNylasSdkError

Error thrown when the SDK receives a non-JSON response with an error status code. This typically happens when the request never reaches the Nylas API due to infrastructure issues (e.g., proxy errors, load balancer failures).

Note: This error class will be used in v7.0 to replace NylasApiError for non-JSON HTTP error responses. Currently, non-JSON errors still throw NylasApiError with type="network_error" for backwards compatibility.

Attributes:

Name Type Description
request_id Optional[str]

The unique identifier of the request.

status_code Optional[int]

The HTTP status code of the error response.

raw_body Optional[str]

The non-JSON response body.

headers Optional[CaseInsensitiveDict]

The headers returned from the server.

flow_id Optional[str]

The value from x-fastly-id header if present.

Source code in nylas/models/errors.py
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
class NylasNetworkError(AbstractNylasSdkError):
    """
    Error thrown when the SDK receives a non-JSON response with an error status code.
    This typically happens when the request never reaches the Nylas API due to
    infrastructure issues (e.g., proxy errors, load balancer failures).

    Note: This error class will be used in v7.0 to replace NylasApiError for non-JSON
    HTTP error responses. Currently, non-JSON errors still throw NylasApiError with 
    type="network_error" for backwards compatibility.

    Attributes:
        request_id: The unique identifier of the request.
        status_code: The HTTP status code of the error response.
        raw_body: The non-JSON response body.
        headers: The headers returned from the server.
        flow_id: The value from x-fastly-id header if present.
    """

    def __init__(
        self,
        message: str,
        request_id: Optional[str] = None,
        status_code: Optional[int] = None,
        raw_body: Optional[str] = None,
        headers: Optional[CaseInsensitiveDict] = None,
        flow_id: Optional[str] = None,
    ):
        """
        Args:
            message: The error message.
            request_id: The unique identifier of the request.
            status_code: The HTTP status code of the error response.
            raw_body: The non-JSON response body.
            headers: The headers returned from the server.
            flow_id: The value from x-fastly-id header if present.
        """
        super().__init__(message)
        self.request_id: Optional[str] = request_id
        self.status_code: Optional[int] = status_code
        self.raw_body: Optional[str] = raw_body
        self.headers: Optional[CaseInsensitiveDict] = headers
        self.flow_id: Optional[str] = flow_id

__init__(message, request_id=None, status_code=None, raw_body=None, headers=None, flow_id=None)

Parameters:

Name Type Description Default
message str

The error message.

required
request_id Optional[str]

The unique identifier of the request.

None
status_code Optional[int]

The HTTP status code of the error response.

None
raw_body Optional[str]

The non-JSON response body.

None
headers Optional[CaseInsensitiveDict]

The headers returned from the server.

None
flow_id Optional[str]

The value from x-fastly-id header if present.

None
Source code in nylas/models/errors.py
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
def __init__(
    self,
    message: str,
    request_id: Optional[str] = None,
    status_code: Optional[int] = None,
    raw_body: Optional[str] = None,
    headers: Optional[CaseInsensitiveDict] = None,
    flow_id: Optional[str] = None,
):
    """
    Args:
        message: The error message.
        request_id: The unique identifier of the request.
        status_code: The HTTP status code of the error response.
        raw_body: The non-JSON response body.
        headers: The headers returned from the server.
        flow_id: The value from x-fastly-id header if present.
    """
    super().__init__(message)
    self.request_id: Optional[str] = request_id
    self.status_code: Optional[int] = status_code
    self.raw_body: Optional[str] = raw_body
    self.headers: Optional[CaseInsensitiveDict] = headers
    self.flow_id: Optional[str] = flow_id

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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
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,
        headers: Optional[CaseInsensitiveDict] = 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, None, status_code, headers)
        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
        self.headers: CaseInsensitiveDict = headers

__init__(oauth_error, status_code=None, headers=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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
def __init__(
    self,
    oauth_error: NylasOAuthErrorResponse,
    status_code: Optional[int] = None,
    headers: Optional[CaseInsensitiveDict] = 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, None, status_code, headers)
    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
    self.headers: CaseInsensitiveDict = headers

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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
@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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
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, headers: Optional[CaseInsensitiveDict] = None):
        """
        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
        self.headers: CaseInsensitiveDict = headers

__init__(url, timeout, headers=None)

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
160
161
162
163
164
165
166
167
168
169
170
171
def __init__(self, url: str, timeout: int, headers: Optional[CaseInsensitiveDict] = None):
    """
    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
    self.headers: CaseInsensitiveDict = headers