Include status code in APIError and handle APIError in the loop (#4995)

This commit is contained in:
jack1142
2021-05-23 16:23:58 +02:00
committed by GitHub
parent b89c43eb0f
commit c4a9d97a4b
3 changed files with 22 additions and 6 deletions

View File

@@ -1,3 +1,6 @@
from typing import Any
class StreamsError(Exception):
pass
@@ -7,7 +10,13 @@ class StreamNotFound(StreamsError):
class APIError(StreamsError):
pass
def __init__(self, status_code: int, raw_data: Any) -> None:
self.status_code = status_code
self.raw_data = raw_data
super().__init__(f"{status_code=} {raw_data=}")
def __repr__(self) -> str:
return f"{self.__class__.__name__}({self!s})"
class InvalidTwitchCredentials(StreamsError):