From Ondra Machacek <omachace(a)redhat.com>:
Ondra Machacek has submitted this change and it was merged.
Change subject: Raise SDK error for unknown tags
......................................................................
Raise SDK error for unknown tags
Currently when the SDK tries to read a document that contains an
unknonwn tag, for example, a document that is actually HTML, it
generates a 'KeyError' because it tries to access a dictionary that
doesn't contain that tag as key. In this situation the SDK should
instead generate a SDK error explaining that there is no reader for that
tag. But that doesn't happen because we are accessing the dictionary
with the '[]' operator, which generates the 'KeyError' when the key
doesn't exist. To avoid that this patch changes the SDK so that it uses
the 'get' method instead, and so that it raises an SDK error instead of
an 'Exception'.
Change-Id: Ifebb1d5d71dfdb3ccccae9ae0596d9fadc5ed1b9
Signed-off-by: Juan Hernandez <juan.hernandez(a)redhat.com>
(cherry picked from commit 4a7fe15baaaaa80bcc48872b040c22913202ac75)
---
M sdk/lib/ovirtsdk4/reader.py
M sdk/tests/test_reader.py
2 files changed, 17 insertions(+), 2 deletions(-)
Approvals:
Ondra Machacek: Verified; Looks good to me, approved
Jenkins CI: Passed CI tests
--
To view, visit
https://gerrit.ovirt.org/69265
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifebb1d5d71dfdb3ccccae9ae0596d9fadc5ed1b9
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine-sdk
Gerrit-Branch: sdk_4.1
Gerrit-Owner: Ondra Machacek <omachace(a)redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Juan Hernandez <juan.hernandez(a)redhat.com>
Gerrit-Reviewer: Ondra Machacek <omachace(a)redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation(a)ovirt.org>