From 59eaceb3ed0cac054a32493874ed66e0cb9fd533 Mon Sep 17 00:00:00 2001 From: Oleg A Date: Fri, 21 Jan 2022 22:55:01 +0300 Subject: [PATCH] fix: don't save error as file Raise an aiohttp.ClientResponseError if the response status is 400 or higher #799 --- aiogram/bot/base.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/aiogram/bot/base.py b/aiogram/bot/base.py index f885e6dc..8fd20949 100644 --- a/aiogram/bot/base.py +++ b/aiogram/bot/base.py @@ -277,7 +277,13 @@ class BaseBot: dest = destination if isinstance(destination, io.IOBase) else open(destination, 'wb') session = await self.get_session() - async with session.get(url, timeout=timeout, proxy=self.proxy, proxy_auth=self.proxy_auth) as response: + async with session.get( + url, + timeout=timeout, + proxy=self.proxy, + proxy_auth=self.proxy_auth, + raise_for_status=True, + ) as response: while True: chunk = await response.content.read(chunk_size) if not chunk: