forked from loafle/openapi-generator-original
[python-experimental] Add support for pep 3134, attach cause of exception (#6388)
* Mustache template should use invokerPackage tag to generate import * Add exception cause * using six module for exception chaining in Python 3.x
This commit is contained in:
parent
912604f3dc
commit
19e14237aa
@ -725,14 +725,14 @@ def deserialize_primitive(data, klass, path_to_item):
|
|||||||
# '7' -> 7.0 -> '7.0' != '7'
|
# '7' -> 7.0 -> '7.0' != '7'
|
||||||
raise ValueError('This is not a float')
|
raise ValueError('This is not a float')
|
||||||
return converted_value
|
return converted_value
|
||||||
except (OverflowError, ValueError):
|
except (OverflowError, ValueError) as ex:
|
||||||
# parse can raise OverflowError
|
# parse can raise OverflowError
|
||||||
raise ApiValueError(
|
six.raise_from(ApiValueError(
|
||||||
"{0}Failed to parse {1} as {2}".format(
|
"{0}Failed to parse {1} as {2}".format(
|
||||||
additional_message, repr(data), get_py3_class_name(klass)
|
additional_message, repr(data), get_py3_class_name(klass)
|
||||||
),
|
),
|
||||||
path_to_item=path_to_item
|
path_to_item=path_to_item
|
||||||
)
|
), ex)
|
||||||
|
|
||||||
|
|
||||||
def get_discriminator_class(model_class,
|
def get_discriminator_class(model_class,
|
||||||
@ -1220,7 +1220,7 @@ def get_allof_instances(self, model_args, constant_args):
|
|||||||
allof_instance = allof_class(**kwargs)
|
allof_instance = allof_class(**kwargs)
|
||||||
composed_instances.append(allof_instance)
|
composed_instances.append(allof_instance)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
raise ApiValueError(
|
six.raise_from(ApiValueError(
|
||||||
"Invalid inputs given to generate an instance of '%s'. The "
|
"Invalid inputs given to generate an instance of '%s'. The "
|
||||||
"input data was invalid for the allOf schema '%s' in the composed "
|
"input data was invalid for the allOf schema '%s' in the composed "
|
||||||
"schema '%s'. Error=%s" % (
|
"schema '%s'. Error=%s" % (
|
||||||
@ -1229,7 +1229,7 @@ def get_allof_instances(self, model_args, constant_args):
|
|||||||
self.__class__.__name__,
|
self.__class__.__name__,
|
||||||
str(ex)
|
str(ex)
|
||||||
)
|
)
|
||||||
)
|
), ex)
|
||||||
return composed_instances
|
return composed_instances
|
||||||
|
|
||||||
|
|
||||||
|
@ -992,14 +992,14 @@ def deserialize_primitive(data, klass, path_to_item):
|
|||||||
# '7' -> 7.0 -> '7.0' != '7'
|
# '7' -> 7.0 -> '7.0' != '7'
|
||||||
raise ValueError('This is not a float')
|
raise ValueError('This is not a float')
|
||||||
return converted_value
|
return converted_value
|
||||||
except (OverflowError, ValueError):
|
except (OverflowError, ValueError) as ex:
|
||||||
# parse can raise OverflowError
|
# parse can raise OverflowError
|
||||||
raise ApiValueError(
|
six.raise_from(ApiValueError(
|
||||||
"{0}Failed to parse {1} as {2}".format(
|
"{0}Failed to parse {1} as {2}".format(
|
||||||
additional_message, repr(data), get_py3_class_name(klass)
|
additional_message, repr(data), get_py3_class_name(klass)
|
||||||
),
|
),
|
||||||
path_to_item=path_to_item
|
path_to_item=path_to_item
|
||||||
)
|
), ex)
|
||||||
|
|
||||||
|
|
||||||
def get_discriminator_class(model_class,
|
def get_discriminator_class(model_class,
|
||||||
@ -1487,7 +1487,7 @@ def get_allof_instances(self, model_args, constant_args):
|
|||||||
allof_instance = allof_class(**kwargs)
|
allof_instance = allof_class(**kwargs)
|
||||||
composed_instances.append(allof_instance)
|
composed_instances.append(allof_instance)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
raise ApiValueError(
|
six.raise_from(ApiValueError(
|
||||||
"Invalid inputs given to generate an instance of '%s'. The "
|
"Invalid inputs given to generate an instance of '%s'. The "
|
||||||
"input data was invalid for the allOf schema '%s' in the composed "
|
"input data was invalid for the allOf schema '%s' in the composed "
|
||||||
"schema '%s'. Error=%s" % (
|
"schema '%s'. Error=%s" % (
|
||||||
@ -1496,7 +1496,7 @@ def get_allof_instances(self, model_args, constant_args):
|
|||||||
self.__class__.__name__,
|
self.__class__.__name__,
|
||||||
str(ex)
|
str(ex)
|
||||||
)
|
)
|
||||||
)
|
), ex)
|
||||||
return composed_instances
|
return composed_instances
|
||||||
|
|
||||||
|
|
||||||
|
@ -992,14 +992,14 @@ def deserialize_primitive(data, klass, path_to_item):
|
|||||||
# '7' -> 7.0 -> '7.0' != '7'
|
# '7' -> 7.0 -> '7.0' != '7'
|
||||||
raise ValueError('This is not a float')
|
raise ValueError('This is not a float')
|
||||||
return converted_value
|
return converted_value
|
||||||
except (OverflowError, ValueError):
|
except (OverflowError, ValueError) as ex:
|
||||||
# parse can raise OverflowError
|
# parse can raise OverflowError
|
||||||
raise ApiValueError(
|
six.raise_from(ApiValueError(
|
||||||
"{0}Failed to parse {1} as {2}".format(
|
"{0}Failed to parse {1} as {2}".format(
|
||||||
additional_message, repr(data), get_py3_class_name(klass)
|
additional_message, repr(data), get_py3_class_name(klass)
|
||||||
),
|
),
|
||||||
path_to_item=path_to_item
|
path_to_item=path_to_item
|
||||||
)
|
), ex)
|
||||||
|
|
||||||
|
|
||||||
def get_discriminator_class(model_class,
|
def get_discriminator_class(model_class,
|
||||||
@ -1487,7 +1487,7 @@ def get_allof_instances(self, model_args, constant_args):
|
|||||||
allof_instance = allof_class(**kwargs)
|
allof_instance = allof_class(**kwargs)
|
||||||
composed_instances.append(allof_instance)
|
composed_instances.append(allof_instance)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
raise ApiValueError(
|
six.raise_from(ApiValueError(
|
||||||
"Invalid inputs given to generate an instance of '%s'. The "
|
"Invalid inputs given to generate an instance of '%s'. The "
|
||||||
"input data was invalid for the allOf schema '%s' in the composed "
|
"input data was invalid for the allOf schema '%s' in the composed "
|
||||||
"schema '%s'. Error=%s" % (
|
"schema '%s'. Error=%s" % (
|
||||||
@ -1496,7 +1496,7 @@ def get_allof_instances(self, model_args, constant_args):
|
|||||||
self.__class__.__name__,
|
self.__class__.__name__,
|
||||||
str(ex)
|
str(ex)
|
||||||
)
|
)
|
||||||
)
|
), ex)
|
||||||
return composed_instances
|
return composed_instances
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user