Skip to content

Commit 9615b60

Browse files
Merge pull request #1135 from adamtheturtle/target-id-on-target-status-processing
Add target ID property to TargetStatusProcessing exception
2 parents c4dd898 + 5f82fee commit 9615b60

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/vws/exceptions.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,16 @@ def response(self) -> Response:
206206
"""
207207
return self._response
208208

209+
@property
210+
def target_id(self) -> str:
211+
"""
212+
The processing target ID.
213+
"""
214+
path = urlparse(self.response.url).path
215+
# Every HTTP path which can raise this error is in the format
216+
# `/something/{target_id}`.
217+
return path.split(sep='/', maxsplit=2)[-1]
218+
209219

210220
class ProjectInactive(Exception):
211221
"""

tests/test_exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ def test_target_status_processing(
210210
vws_client.delete_target(target_id=target_id)
211211

212212
assert exc.value.response.status_code == codes.FORBIDDEN
213+
assert exc.value.target_id == target_id
213214

214215

215216
def test_metadata_too_large(

0 commit comments

Comments
 (0)