mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-31 04:46:26 -06:00
Exception.message was deprecated in Python 2.6 and removed in Python 3
`BaseException.message` was deprecated as of Python 2.6 and is removed in Python 3. Use `str(e)` to access the user-readable message. Use `e.args` to access arguments passed to the exception. $ `python3` ``` >>> dir(Exception('Hey')) ['__cause__', '__class__', '__context__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeof__', '__str__', '__subclasshook__', '__suppress_context__', '__traceback__', 'args', 'with_traceback'] >>> try: ... blah ... except Exception as e: ... print(e) ... print(e.args) ... print(e.message) # Will cause a second Exception ... name 'blah' is not defined ("name 'blah' is not defined",) Traceback (most recent call last): File "<string>", line 2, in <module> NameError: name 'blah' is not defined During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<string>", line 6, in <module> AttributeError: 'NameError' object has no attribute 'message' ```
This commit is contained in:
parent
3feba2997f
commit
dc604ac442
@ -115,7 +115,7 @@ class CustomFieldsMixin(models.Model):
|
||||
try:
|
||||
custom_fields[field_name].validate(value)
|
||||
except ValidationError as e:
|
||||
raise ValidationError(f"Invalid value for custom field '{field_name}': {e.message}")
|
||||
raise ValidationError(f"Invalid value for custom field '{field_name}': {e}")
|
||||
|
||||
# Check for missing required values
|
||||
for cf in custom_fields.values():
|
||||
|
Loading…
Reference in New Issue
Block a user