Bug 1465328 - [RFE] Add a hierarchy of exceptions
[RFE] Add a hierarchy of exceptions
Product: ovirt-engine-sdk-ruby
Classification: oVirt
Component: RFEs (Show other bugs)
Unspecified Unspecified
medium Severity medium (vote)
: ovirt-4.2.0
: 4.2.0.alpha4
Assigned To: Juan Hernández
Radim Hrazdil
: FutureFeature
Depends On:
  Show dependency treegraph
Reported: 2017-06-27 04:48 EDT by Juan Hernández
Modified: 2017-12-20 05:48 EST (History)
6 users (show)

See Also:
Fixed In Version: 4.2.0.alpha4
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2017-12-20 05:48:28 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: Infra
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
rule-engine: ovirt‑4.2+
lsvaty: testing_plan_complete-
mgoldboi: planning_ack+
rule-engine: devel_ack+
lsvaty: testing_ack+

Attachments (Terms of Use)

External Trackers
Tracker ID Priority Status Summary Last Updated
oVirt gerrit 82048 master MERGED Add specific exceptions 2017-09-20 10:39 EDT

  None (edit)
Description Juan Hernández 2017-06-27 04:48:57 EDT
Currently when the SDK detects any kind of problem it raises OvirtSDK4::Error. The raise exception contains details about the error, like the HTTP error code, and the details of the error message generated by the engine. But when the error isn't HTTP related it is difficult to interpret it automatically, as the only information available is the error message. To improve this the SDK should instead provide a hierarchy of exception classes, and raise the ones that are relevant to the situation. This hieararchy should be rooted at the current OvirtSDK4::Error, and should contain at least the following exceptions:

  OvirtSDK4::NotFoundError - When the server returns a 400 HTTP error code.
  OvirtSDK4::TimeoutError - When a request fails after a timeout.
  OvirtSDK4::NoSuchHostError - When the host name can't be resolved.
Comment 1 Juan Hernández 2017-07-05 13:00:06 EDT

  OvirtaSDK4::UnauthorizedError - When the user isn't authorized.

The authentication error should be raised when the SSO service responds with an error or when the API responds with 401.
Comment 2 Juan Hernández 2017-09-20 07:32:05 EDT
The proposed patch adds the following exception classes:

AuthError - Raised when authentication of authorization fail.

ConnectionError - Raised when the name of the server can’t be resolved, and when the server is down or unreachable.

NotFoundError - Raised when the requested object doesn’t exist.

TimeoutError - Raised when an operation times out.
Comment 3 Radim Hrazdil 2017-11-16 10:26:44 EST
Verified that sdk raises specific exception classes proposed in Comment 2. 
SDK version 4.2.0.alpha4, engine 4.2.0-0.0.master.20171108151837.gita7de53e.el7.centos.
Comment 4 Sandro Bonazzola 2017-12-20 05:48:28 EST
This bugzilla is included in oVirt 4.2.0 release, published on Dec 20th 2017.

Since the problem described in this bug report should be
resolved in oVirt 4.2.0 release, published on Dec 20th 2017, it has been closed with a resolution of CURRENT RELEASE.

If the solution does not work for you, please open a new bug report.

Note You need to log in before you can comment on or make changes to this bug.