Skip to content

Commit 4061866

Browse files
authored
Merge pull request #27 from Microsoft/users/tedchamb/se
handle case were service sends back a system exception rather than the proper wrapped exception
2 parents f3300f6 + 8e89dfb commit 4061866

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

vsts/vsts/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from ..customer_intelligence.v4_0.models.customer_intelligence_event import CustomerIntelligenceEvent
1010
from .improper_exception import ImproperException
1111
from ..location.v4_0.models.resource_area_info import ResourceAreaInfo
12+
from .system_exception import SystemException
1213
from .vss_json_collection_wrapper_base import VssJsonCollectionWrapperBase
1314
from .vss_json_collection_wrapper import VssJsonCollectionWrapper
1415
from .wrapped_exception import WrappedException
@@ -18,6 +19,7 @@
1819
'CustomerIntelligenceEvent',
1920
'ImproperException',
2021
'ResourceAreaInfo',
22+
'SystemException',
2123
'VssJsonCollectionWrapperBase',
2224
'VssJsonCollectionWrapper',
2325
'WrappedException'

vsts/vsts/models/system_exception.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Generated file, DO NOT EDIT
4+
# Changes may cause incorrect behavior and will be lost if the code is
5+
# regenerated.
6+
# --------------------------------------------------------------------------
7+
8+
from msrest.serialization import Model
9+
10+
11+
class SystemException(Model):
12+
"""SystemException.
13+
:param class_name:
14+
:type class_name: str
15+
:param inner_exception:
16+
:type inner_exception: :class:`SystemException <vsts.models.SystemException>`
17+
:param message:
18+
:type message: str
19+
"""
20+
21+
_attribute_map = {
22+
'class_name': {'key': 'ClassName', 'type': 'str'},
23+
'message': {'key': 'Message', 'type': 'str'},
24+
'inner_exception': {'key': 'InnerException', 'type': 'SystemException'}
25+
}
26+
27+
def __init__(self, class_name=None, message=None, inner_exception=None):
28+
super(SystemException, self).__init__()
29+
self.class_name = class_name
30+
self.message = message
31+
self.inner_exception = inner_exception

vsts/vsts/models/wrapped_exception.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class WrappedException(Model):
1313
:param exception_id:
1414
:type exception_id: str
1515
:param inner_exception:
16-
:type inner_exception: :class:`WrappedException <vsts.WrappedException>`
16+
:type inner_exception: :class:`WrappedException <vsts.models.WrappedException>`
1717
:param message:
1818
:type message: str
1919
:param type_name:

vsts/vsts/vss_client.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,14 @@ def _handle_error(self, request, response):
227227
# Following code is to handle this unusual exception json case.
228228
# TODO: dig into this.
229229
collection_wrapper = self._base_deserialize('VssJsonCollectionWrapper', response)
230-
if collection_wrapper is not None:
230+
if collection_wrapper is not None and collection_wrapper.value is not None:
231231
wrapped_exception = self._base_deserialize('ImproperException', collection_wrapper.value)
232-
raise VstsClientRequestError(wrapped_exception.message)
232+
if wrapped_exception is not None and wrapped_exception.message is not None:
233+
raise VstsClientRequestError(wrapped_exception.message)
234+
# if we get here we still have not raised an exception, try to deserialize as a System Exception
235+
system_exception = self._base_deserialize('SystemException', response)
236+
if system_exception is not None and system_exception.message is not None:
237+
raise VstsClientRequestError(system_exception.message)
233238
except DeserializationError:
234239
pass
235240
elif response.content is not None:

0 commit comments

Comments
 (0)