1010import json
1111from json import JSONDecodeError
1212import logging
13- import traceback
1413from typing import Any
1514
1615import aiohttp
@@ -83,8 +82,7 @@ async def login(self) -> LoginResponse:
8382 data : LoginResponse = await r .json ()
8483 except (JSONDecodeError , TypeError , aiohttp .ContentTypeError ) as e :
8584 _LOGGER .debug (
86- "Exception: Cannot parse login response:\n %s" ,
87- traceback .format_exc (),
85+ "Exception: Cannot parse login response:\n %s" , exc_info = True
8886 )
8987 raise ParserError (
9088 "Login failed during parsing of request response."
@@ -94,7 +92,7 @@ async def login(self) -> LoginResponse:
9492 raise InvalidAuth
9593 return data
9694 except (TimeoutError , aiohttp .ClientError ) as e :
97- _LOGGER .debug ("Exception: Cannot login:\n %s" , traceback . format_exc () )
95+ _LOGGER .debug ("Exception: Cannot login:\n %s" , exc_info = True )
9896 raise CannotConnect from e
9997
10098 async def get (
@@ -155,7 +153,7 @@ async def get(
155153 _LOGGER .debug (
156154 "Exception: Cannot parse response for %s:\n %s" ,
157155 command ,
158- traceback . format_exc () ,
156+ exc_info = True ,
159157 )
160158 raise ParserError (
161159 "Get {command} failed during parsing of request response."
@@ -167,7 +165,7 @@ async def get(
167165 _LOGGER .debug (
168166 "Exception: Cannot execute command %s:\n %s" ,
169167 command ,
170- traceback . format_exc () ,
168+ exc_info = True ,
171169 )
172170 raise CannotConnect (
173171 "Executing command {command} failed due to request exception"
@@ -240,7 +238,7 @@ async def post(
240238 _LOGGER .debug (
241239 "Exception: Cannot parse response for %s:\n %s" ,
242240 command ,
243- traceback . format_exc () ,
241+ exc_info = True ,
244242 )
245243 raise ParserError (
246244 f"Get { command } failed during parsing of request response."
@@ -252,7 +250,7 @@ async def post(
252250 _LOGGER .debug (
253251 "Exception: Cannot execute command %s:\n %s" ,
254252 command ,
255- traceback . format_exc () ,
253+ exc_info = True ,
256254 )
257255 raise CannotConnect (
258256 f"Executing command { command } failed due to request exception"
0 commit comments