Skip to content

Commit

Permalink
Merge pull request #27 from WhiteApfel/dev
Browse files Browse the repository at this point in the history
🔊 Add response report before raise QiwiError
  • Loading branch information
WhiteApfel authored Jan 22, 2022
2 parents 6674bff + 5e2ee69 commit 65e9d2c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pyqiwip2p/p2p_types/Responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,19 @@ def __init__(self, response: typing.Union[Response, dict], alt="qp2p.0708.su"):
try:
self.r_json = self.r_json.json()
except json.decoder.JSONDecodeError:
fn = f"QiwiCrash_{int(time.time())}.html"
fn = f"QiwiCrash_{int(time.time())}.txt"
Reporter(response).save(fn)
raise ValueError(
f"Code: {response.status_code}. "
f"Qiwi response is not JSON. This is Qiwi-side bug. "
f"Please try again later or check response. "
f"Qiwi response saved to{fn}"
f"Qiwi response saved to {fn}. "
f"P.S. The number of requests per minute may have been exceeded. "
f"You can wait, change auth_key or cry."
)
if "errorCode" in self.r_json:
fn = f"QiwiCrash_{int(time.time())}.txt"
Reporter(response).save(fn)
raise QiwiError(self.r_json)

self.site_id: int = self.r_json["siteId"]
Expand Down

0 comments on commit 65e9d2c

Please sign in to comment.