forked from loafle/openapi-generator-original
Added BadRequestException as a subclass in python (#15722)
Co-authored-by: Gomathi Yoganathan <gyoganathan@C02G45FPMD6R.corp.proofpoint.com>
This commit is contained in:
@@ -116,6 +116,10 @@ class ApiException(OpenApiException):
|
|||||||
|
|
||||||
return error_message
|
return error_message
|
||||||
|
|
||||||
|
class BadRequestException(ApiException):
|
||||||
|
|
||||||
|
def __init__(self, status=None, reason=None, http_resp=None):
|
||||||
|
super(BadRequestException, self).__init__(status, reason, http_resp)
|
||||||
|
|
||||||
class NotFoundException(ApiException):
|
class NotFoundException(ApiException):
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import ssl
|
|||||||
from urllib.parse import urlencode, quote_plus
|
from urllib.parse import urlencode, quote_plus
|
||||||
import urllib3
|
import urllib3
|
||||||
|
|
||||||
from {{packageName}}.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError
|
from {{packageName}}.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError, BadRequestException
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -208,6 +208,9 @@ class RESTClientObject(object):
|
|||||||
logger.debug("response body: %s", r.data)
|
logger.debug("response body: %s", r.data)
|
||||||
|
|
||||||
if not 200 <= r.status <= 299:
|
if not 200 <= r.status <= 299:
|
||||||
|
if r.status == 400:
|
||||||
|
raise BadRequestException(http_resp=r)
|
||||||
|
|
||||||
if r.status == 401:
|
if r.status == 401:
|
||||||
raise UnauthorizedException(http_resp=r)
|
raise UnauthorizedException(http_resp=r)
|
||||||
|
|
||||||
|
|||||||
@@ -127,6 +127,10 @@ class ApiException(OpenApiException):
|
|||||||
|
|
||||||
return error_message
|
return error_message
|
||||||
|
|
||||||
|
class BadRequestException(ApiException):
|
||||||
|
|
||||||
|
def __init__(self, status=None, reason=None, http_resp=None):
|
||||||
|
super(BadRequestException, self).__init__(status, reason, http_resp)
|
||||||
|
|
||||||
class NotFoundException(ApiException):
|
class NotFoundException(ApiException):
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import ssl
|
|||||||
from urllib.parse import urlencode, quote_plus
|
from urllib.parse import urlencode, quote_plus
|
||||||
import urllib3
|
import urllib3
|
||||||
|
|
||||||
from openapi_client.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError
|
from openapi_client.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError, BadRequestException
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -219,6 +219,9 @@ class RESTClientObject(object):
|
|||||||
logger.debug("response body: %s", r.data)
|
logger.debug("response body: %s", r.data)
|
||||||
|
|
||||||
if not 200 <= r.status <= 299:
|
if not 200 <= r.status <= 299:
|
||||||
|
if r.status == 400:
|
||||||
|
raise BadRequestException(http_resp=r)
|
||||||
|
|
||||||
if r.status == 401:
|
if r.status == 401:
|
||||||
raise UnauthorizedException(http_resp=r)
|
raise UnauthorizedException(http_resp=r)
|
||||||
|
|
||||||
|
|||||||
@@ -126,6 +126,10 @@ class ApiException(OpenApiException):
|
|||||||
|
|
||||||
return error_message
|
return error_message
|
||||||
|
|
||||||
|
class BadRequestException(ApiException):
|
||||||
|
|
||||||
|
def __init__(self, status=None, reason=None, http_resp=None):
|
||||||
|
super(BadRequestException, self).__init__(status, reason, http_resp)
|
||||||
|
|
||||||
class NotFoundException(ApiException):
|
class NotFoundException(ApiException):
|
||||||
|
|
||||||
|
|||||||
@@ -126,6 +126,10 @@ class ApiException(OpenApiException):
|
|||||||
|
|
||||||
return error_message
|
return error_message
|
||||||
|
|
||||||
|
class BadRequestException(ApiException):
|
||||||
|
|
||||||
|
def __init__(self, status=None, reason=None, http_resp=None):
|
||||||
|
super(BadRequestException, self).__init__(status, reason, http_resp)
|
||||||
|
|
||||||
class NotFoundException(ApiException):
|
class NotFoundException(ApiException):
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import ssl
|
|||||||
from urllib.parse import urlencode, quote_plus
|
from urllib.parse import urlencode, quote_plus
|
||||||
import urllib3
|
import urllib3
|
||||||
|
|
||||||
from petstore_api.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError
|
from petstore_api.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError, BadRequestException
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -218,6 +218,9 @@ class RESTClientObject(object):
|
|||||||
logger.debug("response body: %s", r.data)
|
logger.debug("response body: %s", r.data)
|
||||||
|
|
||||||
if not 200 <= r.status <= 299:
|
if not 200 <= r.status <= 299:
|
||||||
|
if r.status == 400:
|
||||||
|
raise BadRequestException(http_resp=r)
|
||||||
|
|
||||||
if r.status == 401:
|
if r.status == 401:
|
||||||
raise UnauthorizedException(http_resp=r)
|
raise UnauthorizedException(http_resp=r)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user