Skip to content

Introduce raise_on_error_status flag #736

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ def _get_kwargs(
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
if response.status_code == HTTPStatus.OK:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")
if response.status_code >= 400:
if client.raise_on_unexpected_status or client.raise_on_error_status:
raise errors.UnexpectedErrorStatus(f"Unexpected status code: {response.status_code}")
else:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedSuccessStatus(f"Unexpected status code: {response.status_code}")
return None


def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
Expand All @@ -61,6 +64,7 @@ def sync_detailed(
common (Union[Unset, None, str]):

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand Down Expand Up @@ -91,6 +95,7 @@ async def asyncio_detailed(
common (Union[Unset, None, str]):

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ def _get_kwargs(
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
if response.status_code == HTTPStatus.OK:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")
if response.status_code >= 400:
if client.raise_on_unexpected_status or client.raise_on_error_status:
raise errors.UnexpectedErrorStatus(f"Unexpected status code: {response.status_code}")
else:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedSuccessStatus(f"Unexpected status code: {response.status_code}")
return None


def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
Expand All @@ -61,6 +64,7 @@ def sync_detailed(
common (Union[Unset, None, str]):

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand Down Expand Up @@ -91,6 +95,7 @@ async def asyncio_detailed(
common (Union[Unset, None, str]):

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@ def _get_kwargs(
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
if response.status_code == HTTPStatus.OK:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")
if response.status_code >= 400:
if client.raise_on_unexpected_status or client.raise_on_error_status:
raise errors.UnexpectedErrorStatus(f"Unexpected status code: {response.status_code}")
else:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedSuccessStatus(f"Unexpected status code: {response.status_code}")
return None


def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
Expand Down Expand Up @@ -90,6 +93,7 @@ def sync_detailed(
string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]):

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand Down Expand Up @@ -135,6 +139,7 @@ async def asyncio_detailed(
string_enum_header (Union[Unset, GetLocationHeaderTypesStringEnumHeader]):

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ def _get_kwargs(
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
if response.status_code == HTTPStatus.OK:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")
if response.status_code >= 400:
if client.raise_on_unexpected_status or client.raise_on_error_status:
raise errors.UnexpectedErrorStatus(f"Unexpected status code: {response.status_code}")
else:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedSuccessStatus(f"Unexpected status code: {response.status_code}")
return None


def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
Expand Down Expand Up @@ -91,6 +94,7 @@ def sync_detailed(
not_null_not_required (Union[Unset, None, datetime.datetime]):

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand Down Expand Up @@ -130,6 +134,7 @@ async def asyncio_detailed(
not_null_not_required (Union[Unset, None, datetime.datetime]):

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ def _get_kwargs(
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
if response.status_code == HTTPStatus.OK:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")
if response.status_code >= 400:
if client.raise_on_unexpected_status or client.raise_on_error_status:
raise errors.UnexpectedErrorStatus(f"Unexpected status code: {response.status_code}")
else:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedSuccessStatus(f"Unexpected status code: {response.status_code}")
return None


def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
Expand Down Expand Up @@ -80,6 +83,7 @@ def sync_detailed(
cookie_param (str):

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand Down Expand Up @@ -123,6 +127,7 @@ async def asyncio_detailed(
cookie_param (str):

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ def _get_kwargs(
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
if response.status_code == HTTPStatus.OK:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")
if response.status_code >= 400:
if client.raise_on_unexpected_status or client.raise_on_error_status:
raise errors.UnexpectedErrorStatus(f"Unexpected status code: {response.status_code}")
else:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedSuccessStatus(f"Unexpected status code: {response.status_code}")
return None


def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
Expand All @@ -64,6 +67,7 @@ def sync_detailed(
param_query (Union[Unset, None, str]):

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand Down Expand Up @@ -97,6 +101,7 @@ async def asyncio_detailed(
param_query (Union[Unset, None, str]):

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ def _get_kwargs(
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
if response.status_code == HTTPStatus.OK:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")
if response.status_code >= 400:
if client.raise_on_unexpected_status or client.raise_on_error_status:
raise errors.UnexpectedErrorStatus(f"Unexpected status code: {response.status_code}")
else:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedSuccessStatus(f"Unexpected status code: {response.status_code}")
return None


def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
Expand All @@ -66,6 +69,7 @@ def sync_detailed(
'overridden_in_GET'. Example: an example string.

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand Down Expand Up @@ -101,6 +105,7 @@ async def asyncio_detailed(
'overridden_in_GET'. Example: an example string.

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ def _get_kwargs(
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
if response.status_code == HTTPStatus.OK:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")
if response.status_code >= 400:
if client.raise_on_unexpected_status or client.raise_on_error_status:
raise errors.UnexpectedErrorStatus(f"Unexpected status code: {response.status_code}")
else:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedSuccessStatus(f"Unexpected status code: {response.status_code}")
return None


def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
Expand Down Expand Up @@ -76,6 +79,7 @@ def sync_detailed(
param_cookie (Union[Unset, str]):

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand Down Expand Up @@ -115,6 +119,7 @@ async def asyncio_detailed(
param_cookie (Union[Unset, str]):

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ def _get_kwargs(
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
if response.status_code == HTTPStatus.OK:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")
if response.status_code >= 400:
if client.raise_on_unexpected_status or client.raise_on_error_status:
raise errors.UnexpectedErrorStatus(f"Unexpected status code: {response.status_code}")
else:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedSuccessStatus(f"Unexpected status code: {response.status_code}")
return None


def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
Expand Down Expand Up @@ -66,6 +69,7 @@ def sync_detailed(
param3 (int):

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand Down Expand Up @@ -105,6 +109,7 @@ async def asyncio_detailed(
param3 (int):

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ def _parse_response(
response_200 = PostResponsesUnionsSimpleBeforeComplexResponse200.from_dict(response.json())

return response_200
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")
if response.status_code >= 400:
if client.raise_on_unexpected_status or client.raise_on_error_status:
raise errors.UnexpectedErrorStatus(f"Unexpected status code: {response.status_code}")
else:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedSuccessStatus(f"Unexpected status code: {response.status_code}")
return None


def _build_response(
Expand All @@ -60,6 +63,7 @@ def sync_detailed(
"""Regression test for #603

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand All @@ -86,6 +90,7 @@ def sync(
"""Regression test for #603

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand All @@ -105,6 +110,7 @@ async def asyncio_detailed(
"""Regression test for #603

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand All @@ -129,6 +135,7 @@ async def asyncio(
"""Regression test for #603

Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ def _get_kwargs(
def _parse_response(*, client: Client, response: httpx.Response) -> Optional[Any]:
if response.status_code == HTTPStatus.OK:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedStatus(f"Unexpected status code: {response.status_code}")
if response.status_code >= 400:
if client.raise_on_unexpected_status or client.raise_on_error_status:
raise errors.UnexpectedErrorStatus(f"Unexpected status code: {response.status_code}")
else:
return None
if client.raise_on_unexpected_status:
raise errors.UnexpectedSuccessStatus(f"Unexpected status code: {response.status_code}")
return None


def _build_response(*, client: Client, response: httpx.Response) -> Response[Any]:
Expand All @@ -50,6 +53,7 @@ def sync_detailed(
) -> Response[Any]:
"""
Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand All @@ -75,6 +79,7 @@ async def asyncio_detailed(
) -> Response[Any]:
"""
Raises:
errors.ErrorStatus: If the server returns an error status code and Client.raise_on_error_status is True.
errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True.
httpx.TimeoutException: If the request takes longer than Client.timeout.

Expand Down
Loading