From ca010ac5226501cf979fde12ecdd646e8ca781aa Mon Sep 17 00:00:00 2001 From: Bas Stottelaar Date: Sat, 12 Apr 2014 20:35:15 +0200 Subject: [PATCH] Prevent misleading messages about whitelisting --- headphones/request.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/headphones/request.py b/headphones/request.py index 0e970f40..9892592e 100644 --- a/headphones/request.py +++ b/headphones/request.py @@ -30,8 +30,11 @@ def request_response(url, method="get", auto_raise=True, whitelist_status_code=N # is white listed. if whitelist_status_code and auto_raise: if response.status_code not in whitelist_status_code: - logger.debug("Response status code %d is not white listed, raising exception", response.status_code) - response.raise_for_status() + try: + response.raise_for_status() + except: + logger.debug("Response status code %d is not white listed, raised exception", response.status_code) + raise elif auto_raise: response.raise_for_status()