kopia lustrzana https://github.com/snarfed/bridgy-fed
tell common.error() explicitly when to include exc_info
rodzic
fff036b5e6
commit
bb9294ea51
|
@ -72,8 +72,8 @@ class InboxHandler(webapp2.RequestHandler):
|
|||
try:
|
||||
activity = json.loads(self.request.body)
|
||||
assert activity
|
||||
except (TypeError, ValueError, AssertionError) as e:
|
||||
common.error(self, "Couldn't parse body as JSON: %s" % e)
|
||||
except (TypeError, ValueError, AssertionError):
|
||||
common.error(self, "Couldn't parse body as JSON", exc_info=True)
|
||||
|
||||
type = activity.get('type')
|
||||
if type not in SUPPORTED_TYPES:
|
||||
|
|
|
@ -24,9 +24,9 @@ class AddWebmentionHandler(webapp2.RequestHandler):
|
|||
try:
|
||||
resp = common.requests_get(url)
|
||||
except requests.exceptions.Timeout as e:
|
||||
common.error(self, unicode(e), status=504)
|
||||
common.error(self, unicode(e), status=504, exc_info=True)
|
||||
except requests.exceptions.RequestException as e:
|
||||
common.error(self, unicode(e), status=502)
|
||||
common.error(self, unicode(e), status=502, exc_info=True)
|
||||
|
||||
self.response.status_int = resp.status_code
|
||||
self.response.write(resp.content)
|
||||
|
|
|
@ -62,16 +62,15 @@ def _requests_fn(fn, url, parse_json=False, log=False, **kwargs):
|
|||
try:
|
||||
return resp.json()
|
||||
except ValueError as e:
|
||||
common.error("Couldn't parse response from %s as JSON: %s\n%s" %
|
||||
(url, e, resp.text), exc_info=True, status=502)
|
||||
common.error("Couldn't parse response as JSON", exc_info=True, status=502)
|
||||
|
||||
return resp
|
||||
|
||||
|
||||
def error(handler, msg, status=None):
|
||||
def error(handler, msg, status=None, exc_info=False):
|
||||
if not status:
|
||||
status = 400
|
||||
logging.info('Returning %s: %s' % (status, msg), exc_info=True)
|
||||
logging.info('Returning %s: %s' % (status, msg), exc_info=exc_info)
|
||||
handler.abort(status, msg)
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class SlapHandler(webapp2.RequestHandler):
|
|||
try:
|
||||
parsed = utils.parse_magic_envelope(self.request.body)
|
||||
except ParseError as e:
|
||||
common.error(self, 'Could not parse POST body as XML: %s' % e)
|
||||
common.error(self, 'Could not parse POST body as XML', exc_info=True)
|
||||
data = utils.decode(parsed['data'])
|
||||
logging.info('Decoded: %s', data)
|
||||
|
||||
|
@ -47,7 +47,7 @@ class SlapHandler(webapp2.RequestHandler):
|
|||
try:
|
||||
activity = atom.atom_to_activity(data)
|
||||
except ParseError as e:
|
||||
common.error(self, 'Could not parse envelope data as XML: %s' % e)
|
||||
common.error(self, 'Could not parse envelope data as XML', exc_info=True)
|
||||
|
||||
verb = activity.get('verb')
|
||||
if verb and verb not in SUPPORTED_VERBS:
|
||||
|
|
Ładowanie…
Reference in New Issue