Skip to content

Commit

Permalink
[uss_qualifier] add utility properties to QueryError
Browse files Browse the repository at this point in the history
  • Loading branch information
Shastick committed Mar 8, 2024
1 parent fa4b7d7 commit efe9d4c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions monitoring/monitorlib/fetch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,19 @@ def __init__(self, msg: str, queries: Optional[Union[Query, List[Query]]] = None
else:
self.queries = queries

@property
def last_status_code(self) -> int:
"""Returns the status code of the last query present in this QueryError,
or 999 if this error contains no queries."""
if len(self.queries) == 0:
return 999
return self.queries[-1].status_code

@property
def query_timestamps(self) -> List[datetime.datetime]:
"""Returns the timestamps of all queries present in this QueryError."""
return [q.request.timestamp for q in self.queries]

@property
def stacktrace(self) -> str:
return stacktrace_string(self)
Expand Down

0 comments on commit efe9d4c

Please sign in to comment.