Browse Source

Exception JSON format.

pull/12/head
Marcos Pereira 7 years ago
parent
commit
140875d7ce
  1. 5
      keycloak/exceptions.py

5
keycloak/exceptions.py

@ -14,6 +14,7 @@
# #
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from json.decoder import JSONDecodeError
import requests import requests
@ -80,7 +81,11 @@ 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:
return response.json() return response.json()
except JSONDecodeError as e:
return response.content
try: try:
message = response.json()['message'] message = response.json()['message']

Loading…
Cancel
Save