Open joewesch opened 10 months ago
Thoughts on below?
dtif = DeviceTypeImportForm(data)
if not dtif.is_valid():
raise ValueError(f"Unable to import this device_type, {dtif.errors}")
dtif.save()
Not verified and not sure if the error you're trying to account for is covered. Also I would have thought it would raise ValidationError
instead of ValueError
.
Environment
Proposed Functionality
When loading a custom yaml file for a DeviceType, required fields may be missed and the only error that we get is from the form's
.save()
method. This error message, unfortunately, isn't too helpful:We should wrap the save method in a try block and if it fails look for validation errors to present to the user. Here is an example of a possible change to the existing code:
Use Case