The ovirtsdk4.Error is a basic wrapping around an generic python exception. I did try introspection of it's content and sees nothing else than a raw string argument. For example: args ('Fault reason is "Operation Failed". Fault detail is "[Cannot switch the following Hosts to Maintenance mode: XXX.\nOne or more running VMs are indicated as non-migratable. The non-migratable VMs are: XXX , XXX.]". HTTP response code is 409.',) As I used the sdk in a bigger application I would like to have in this case 3 variables: The fault reasons: "Operation Failed" The fault detail: "[Cannot switch the following Hosts to Maintenance mode: XXX.\nOne or more running VMs are indicated as non-migratable. The non-migratable VMs are: XXX , XXX.]" The error code : 409. That should be easy, they are all part of the returned message: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <action> <async>true</async> <fault> <detail>[Cannot switch the following Hosts to Maintenance mode: XXX. One or more running VMs are indicated as non-migratable. The non-migratable VMs are: XXX , XXX.]</detail> <reason>Operation Failed</reason> </fault> <reason>For upgrade</reason> <status>failed</status> </action> I can then build a custom message with the details I need. For example, I don't think the HTTP response code is generally useful, unless in debug mode. What do you think of that ?
Another use case where a smart exception would be useful: ovirtsdk4.Error: Error during SSO revoke server_error : UT000021: Session already invalidated I can catch this exception and transform it as a warning or a notice if details can be used, instead of having to use a brittle regex.
Yes, that can be useful. I'd suggest to add two properties: 'code' and 'fault'. The first should be an integer containing the HTTP response code. The second should be an instance of the 'Fault' type, containing the detail and reason. Both should be optional, as certain errors won't have an HTTP error code or a fault (timeout, for example).
Verified in python-ovirt-engine-sdk4-4.1.4-1.el7ev.x86_64