From f2fee5a84e62874ba6b252cb02203f6e4e7e88f9 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Fri, 18 Jul 2014 09:20:00 +1000 Subject: [PATCH] Return a HTTP 500 instead of a HTTP 400 if an internal error occurs in the Aphlict server Summary: Ref T5651. Only throw a HTTP 400 if the data is invalid (i.e. the request is bad). If something bad happens when trying to transmit the notification, throw a HTTP 500 instead. Test Plan: Eye-ball it. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Maniphest Tasks: T5651 Differential Revision: https://secure.phabricator.com/D9968 --- support/aphlict/server/aphlict_server.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/support/aphlict/server/aphlict_server.js b/support/aphlict/server/aphlict_server.js index f079a059bd..f6dd53dbf9 100644 --- a/support/aphlict/server/aphlict_server.js +++ b/support/aphlict/server/aphlict_server.js @@ -177,9 +177,18 @@ var receive_server = http.createServer(function(request, response) { debug.log('notification: ' + JSON.stringify(msg)); ++messages_in; - transmit(msg); - response.writeHead(200, {'Content-Type': 'text/plain'}); + try { + transmit(msg); + response.writeHead(200, {'Content-Type': 'text/plain'}); + } catch (err) { + debug.log( + '<%s> Internal Server Error! %s', + request.socket.remoteAddress, + err); + response.statusCode = 500; + response.write('500 Internal Server Error\n'); + } } catch (err) { debug.log( '<%s> Bad Request! %s',