raise HTTPError for a better handling of 401 and so on

This commit is contained in:
Olivier Demah
2016-05-01 00:39:36 +02:00
parent 944e1302d8
commit 07f6057421
2 changed files with 5 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
# coding: utf-8
import requests
from requests import HTTPError
import logging
__author__ = 'foxmask'
@@ -88,7 +89,7 @@ class Wallabag(object):
:return the json data without 'root' node
"""
if responses.status_code != 200:
raise Exception("Wrong status code: ", responses.status_code)
raise HTTPError(responses.status_code, responses.json())
json_data = {}
try:
json_data = responses.json()