Browse Source

A decoder error is a ValueError allows us to catch all decode errors from requests without force install simplejson

hotfix/merge
Shon T. Urbas 7 years ago
parent
commit
944e2a7a39
  1. 4
      keycloak/exceptions.py

4
keycloak/exceptions.py

@ -16,7 +16,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import requests import requests
from json import JSONDecodeError
class KeycloakError(Exception): class KeycloakError(Exception):
@ -73,10 +72,9 @@ def raise_error_from_response(response, error, expected_code=200):
if expected_code == response.status_code: if expected_code == response.status_code:
if expected_code == requests.codes.no_content: if expected_code == requests.codes.no_content:
return {} return {}
try: try:
return response.json() return response.json()
except JSONDecodeError as e:
except ValueError:
return response.content return response.content
try: try:

Loading…
Cancel
Save