File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed
Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 99 AuthorizationException ,
1010 BadRequestException ,
1111 BaseRequestException ,
12+ ConflictException ,
1213 ServerException ,
1314)
1415from workos .utils .http_client import SyncHTTPClient
@@ -251,6 +252,23 @@ def test_request_bad_body_raises_expected_exception_with_request_data(self):
251252 # This'll fail for sure here but... just using the nice error that'd come up
252253 assert ex .__class__ == ServerException
253254
255+ def test_conflict_exception (self ):
256+ request_id = "request-123"
257+
258+ self .http_client ._client .request = MagicMock (
259+ return_value = httpx .Response (
260+ status_code = 409 ,
261+ headers = {"X-Request-ID" : request_id },
262+ ),
263+ )
264+
265+ try :
266+ self .http_client .request ("bad_place" )
267+ except ConflictException as ex :
268+ assert str (ex ) == "(message=No message, request_id=request-123)"
269+ except Exception as ex :
270+ assert ex .__class__ == ConflictException
271+
254272 def test_request_includes_base_headers (self , capture_and_mock_http_client_request ):
255273 request_kwargs = capture_and_mock_http_client_request (self .http_client , {}, 200 )
256274
Original file line number Diff line number Diff line change @@ -53,6 +53,10 @@ class BadRequestException(BaseRequestException):
5353 pass
5454
5555
56+ class ConflictException (BaseRequestException ):
57+ pass
58+
59+
5660class NotFoundException (BaseRequestException ):
5761 pass
5862
Original file line number Diff line number Diff line change 1616from httpx ._types import QueryParamTypes
1717
1818from workos .exceptions import (
19+ ConflictException ,
1920 ServerException ,
2021 AuthenticationException ,
2122 AuthorizationException ,
@@ -101,6 +102,8 @@ def _maybe_raise_error_by_status_code(
101102 raise AuthorizationException (response , response_json )
102103 elif status_code == 404 :
103104 raise NotFoundException (response , response_json )
105+ elif status_code == 409 :
106+ raise ConflictException (response , response_json )
104107
105108 raise BadRequestException (response , response_json )
106109 elif status_code >= 500 and status_code < 600 :
You can’t perform that action at this time.
0 commit comments