[docs]11classAPIError(Exception):12"""An error received from the ntfy API.1314 :param response: The :class:`httpx.Response` object that encountered15 the error.16 :type response: httpx.Response17 :param stream: Whether or not the response is streaming.18 :type stream: bool1920 """2122def__init__(self,response:httpx.Response,stream:bool)->None:23try:24data:dict[str,Union[str,int]]=json.loads(25next(response.iter_lines())ifstreamelseresponse.content26)27msg="; ".join(28f"{k}={v!r}"29fork,vin(30(k,data.get(k))forkin("http","code","error","link")31)32ifvisnotNone33)34super().__init__(f"Error interacting with the API ({msg})")35exceptException:36super().__init__(37"Error interacting with the API (http:"38f" {response.status_code})"39)