Skip to content

Commit 9c3700e

Browse files
Merge pull request #1136 from adamtheturtle/target-id-on-target-status-processing
Add target ID to TargetStatusNotSuccess
2 parents 26934aa + 393fef8 commit 9c3700e

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
@@ -350,6 +350,16 @@ def response(self) -> Response:
350350
"""
351351
return self._response
352352

353+
@property
354+
def target_id(self) -> str:
355+
"""
356+
The unknown target ID.
357+
"""
358+
path = urlparse(self.response.url).path
359+
# Every HTTP path which can raise this error is in the format
360+
# `/something/{target_id}`.
361+
return path.split(sep='/', maxsplit=2)[-1]
362+
353363

354364
# See https://github.com/adamtheturtle/vws-python/issues/846.
355365
class DateRangeError(Exception): # pragma: no cover

tests/test_exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ def test_target_status_not_success(
311311
vws_client.update_target(target_id=target_id)
312312

313313
assert exc.value.response.status_code == codes.FORBIDDEN
314+
assert exc.value.target_id == target_id
314315

315316

316317
def test_match_processing(

0 commit comments

Comments
 (0)