mirror of https://github.com/OpenKMIP/PyKMIP.git
Added TypeError exception to Name.create method
This commit is contained in:
parent
ceaff6d7ac
commit
e67f56ae56
|
@ -108,13 +108,25 @@ class Name(Struct):
|
|||
value = name_value
|
||||
elif isinstance(name_value, str):
|
||||
value = cls.NameValue(name_value)
|
||||
# else: the __validate function will throw TypeError
|
||||
else:
|
||||
name = self.__class__.__name__
|
||||
msg = ErrorStrings.BAD_EXP_RECV
|
||||
member = 'name_value'
|
||||
raise TypeError(msg.format('{}.{}'.format(name, member),
|
||||
'name_value', type(Name.NameValue),
|
||||
type(self.name_value)))
|
||||
|
||||
if isinstance(name_type, Name.NameType):
|
||||
n_type = name_type
|
||||
elif isinstance(name_type, Enum):
|
||||
n_type = cls.NameType(name_type)
|
||||
# else: the __validate function will throw TypeError
|
||||
else:
|
||||
name = self.__class__.__name__
|
||||
msg = ErrorStrings.BAD_EXP_RECV
|
||||
member = 'name_type'
|
||||
raise TypeError(msg.format('{}.{}'.format(name, member),
|
||||
'name_type', type(Name.NameType),
|
||||
type(self.name_type)))
|
||||
|
||||
return Name(name_value=value,
|
||||
name_type=n_type)
|
||||
|
|
Loading…
Reference in New Issue