From 4f1cf507797d2fde03e40995aeaba7b7ceae4685 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 28 May 2020 16:57:10 +0200 Subject: [PATCH] Raise ExternalError on 400+ responses for pug --- royalpack/commands/pug.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/royalpack/commands/pug.py b/royalpack/commands/pug.py index 97b66834..6846212b 100644 --- a/royalpack/commands/pug.py +++ b/royalpack/commands/pug.py @@ -16,6 +16,8 @@ class PugCommand(rc.Command): async def run(self, args: rc.CommandArgs, data: rc.CommandData) -> None: async with aiohttp.ClientSession() as session: async with session.get("https://dog.ceo/api/breed/pug/images/random") as response: + if response.status >= 400: + raise rc.ExternalError(f"Request returned {response.status}") result = await response.json() assert "status" in result assert result["status"] == "success"