forked from loafle/openapi-generator-original
Fix(Python): Add custom exceptions for HTTP status codes 409 (Conflict) and 422 (Unprocessable Entity) #20244 (#20251)
* Update exceptions.mustache * Fix(Python): Add custom exceptions for HTTP status codes 409 (Conflict) and 422 (Unprocessable Entity) #20244
This commit is contained in:
@@ -150,6 +150,14 @@ class ApiException(OpenApiException):
|
||||
if http_resp.status == 404:
|
||||
raise NotFoundException(http_resp=http_resp, body=body, data=data)
|
||||
|
||||
# Added new exception classes for 409 and 422
|
||||
|
||||
if http_resp.status == 409:
|
||||
raise ConflictException(http_resp=http_resp, body=body, data=data)
|
||||
|
||||
if http_resp.status == 422:
|
||||
raise UnprocessableEntityException(http_resp=http_resp, body=body, data=data)
|
||||
|
||||
if 500 <= http_resp.status <= 599:
|
||||
raise ServiceException(http_resp=http_resp, body=body, data=data)
|
||||
raise ApiException(http_resp=http_resp, body=body, data=data)
|
||||
@@ -183,6 +191,14 @@ class UnauthorizedException(ApiException):
|
||||
class ForbiddenException(ApiException):
|
||||
pass
|
||||
|
||||
class ConflictException(ApiException):
|
||||
"""Exception raised for HTTP 409 Conflict errors."""
|
||||
pass
|
||||
|
||||
|
||||
class UnprocessableEntityException(ApiException):
|
||||
"""Exception raised for HTTP 422 Unprocessable Entity errors."""
|
||||
pass
|
||||
|
||||
class ServiceException(ApiException):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user