Skip to content

Commit

Permalink
Code cleanup, used send_error method
Browse files Browse the repository at this point in the history
  • Loading branch information
ftsalamp authored and danielballan committed May 11, 2018
1 parent 6de1d38 commit b54ad85
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions web_monitoring/diffing_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,6 @@

client = tornado.httpclient.AsyncHTTPClient()

def handle_request(response):
if response.error is not None:
try:
response.rethrow()
except ValueError:
print("This is a value error")

else:
print('Handle request')

class DiffHandler(tornado.web.RequestHandler):
# subclass must define `differs` attribute

Expand All @@ -97,26 +87,17 @@ def get(self, differ):
try:
res_a.rethrow()
except (ValueError, IOError):
pdb.set_trace()
data = {}
data['code'] = res_a.code
data['error'] = str(res_a.error)
data['parameter'] = 'a'
json_data = json.dumps(data)
self.write(json_data)
self.send_error(
res_a.code, reason=str(res_a.error))

return

if res_b.error is not None:
try:
res_b.rethrow()
except (ValueError, IOError):
pdb.set_trace()
data = {}
data['code'] = res_b.code
data['error'] = str(res_b.error)
data['parameter'] = 'b'
json_data = json.dumps(data)
self.write(json_data)
self.send_error(
res_b.code, reason=str(res_b.error))
return


Expand Down

0 comments on commit b54ad85

Please sign in to comment.