Change in ovirt-engine-sdk[master]: Improve error message for wrong content type

Code Review gerrit at ovirt.org
Wed Apr 12 12:57:44 UTC 2017


>From Ondra Machacek <omachace at redhat.com>:

Ondra Machacek has submitted this change and it was merged.

Change subject: Improve error message for wrong content type
......................................................................


Improve error message for wrong content type

Currently when the user specifies an incorrect URL path the SDK sends
requests to the server anyhow, and it tries to parse the response body
as XML, without checking the response content type. This generates error
messages that don't explain the root cause of the problem. To improve
that this patch changes the SDK so that it checks the content type of
the responses and generates error messages that explain better the
failure. For example, if the user specifies an incorrect URL path like
'/ugly', the SDK will try to contact the server and will raise an
exception containing the following error message:

   The response content type 'text/html; charset=iso-8859-1' isn't
   the expected XML. Is the path '/ugly' included in the 'url'
   parameter correct? The typical one is '/ovirt-engine/api'

Change-Id: I548ae621a025969fe2dbf086f49ba83ea52fc28f
Bug-Url: https://bugzilla.redhat.com/1440292
Signed-off-by: Juan Hernandez <juan.hernandez at redhat.com>
Signed-off-by: Ondra Machacek <omachace at redhat.com>
---
M sdk/lib/ovirtsdk4/__init__.py
M sdk/tests/server.py
2 files changed, 62 insertions(+), 1 deletion(-)

Approvals:
  Ondra Machacek: Verified; Looks good to me, approved
  Juan Hernandez: Looks good to me, but someone else must approve
  Jenkins CI: Passed CI tests



-- 
To view, visit https://gerrit.ovirt.org/75433
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I548ae621a025969fe2dbf086f49ba83ea52fc28f
Gerrit-PatchSet: 5
Gerrit-Project: ovirt-engine-sdk
Gerrit-Branch: master
Gerrit-Owner: Ondra Machacek <omachace at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Juan Hernandez <juan.hernandez at redhat.com>
Gerrit-Reviewer: Ondra Machacek <omachace at redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>


More information about the Engine-commits mailing list