mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 03:20:59 +01:00
Catch errors that may occur whilst receiving data from the Aphlict server.
Summary: Ref T4324. Currently, if the `AphlictMaster` receives dodgy data from the Aphlict server (invalid JSON, for example) then a syntax error will be thrown and the `AphlictMaster` will die. Instead, catch errors and raise a notification. Test Plan: {F163466} Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T4324 Differential Revision: https://secure.phabricator.com/D9380
This commit is contained in:
parent
ba2ce8a5ca
commit
8033a69746
4 changed files with 65 additions and 44 deletions
|
@ -31,6 +31,10 @@ package {
|
|||
ExternalInterface.call('JX.Aphlict.didReceiveEvent', type, object);
|
||||
}
|
||||
|
||||
protected function error(error:Error):void {
|
||||
this.externalInvoke('error', error.toString());
|
||||
}
|
||||
|
||||
protected function log(message:String):void {
|
||||
this.externalInvoke('log', message);
|
||||
}
|
||||
|
|
|
@ -131,6 +131,7 @@ package {
|
|||
}
|
||||
|
||||
private function didReceiveSocket(event:Event):void {
|
||||
try {
|
||||
var b:ByteArray = this.readBuffer;
|
||||
this.socket.readBytes(b, b.length);
|
||||
|
||||
|
@ -159,6 +160,9 @@ package {
|
|||
break;
|
||||
}
|
||||
} while (true);
|
||||
} catch (err:Error) {
|
||||
this.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,8 +24,20 @@ JX.behavior('aphlict-listen', function(config) {
|
|||
// Respond to a notification from the Aphlict notification server. We send
|
||||
// a request to Phabricator to get notification details.
|
||||
function onaphlictmessage(type, message) {
|
||||
if (type == 'receive') {
|
||||
var routable = new JX.Request('/notification/individual/', onnotification)
|
||||
switch (type) {
|
||||
case 'error':
|
||||
new JX.Notification()
|
||||
.setContent('(Aphlict) ' + message)
|
||||
.alterClassName('jx-notification-error', true)
|
||||
.show();
|
||||
break;
|
||||
|
||||
case 'receive':
|
||||
var routable = new JX.Request(
|
||||
'/notification/individual/',
|
||||
onnotification);
|
||||
|
||||
routable
|
||||
.addData({key: message.key})
|
||||
.getRoutable();
|
||||
|
||||
|
@ -34,8 +46,10 @@ JX.behavior('aphlict-listen', function(config) {
|
|||
.setPriority(250);
|
||||
|
||||
JX.Router.getInstance().queue(routable);
|
||||
} else if (__DEV__) {
|
||||
if (config.debug) {
|
||||
break;
|
||||
|
||||
default:
|
||||
if (__DEV__ && config.debug) {
|
||||
var details = message ? JX.JSON.stringify(message) : '';
|
||||
|
||||
new JX.Notification()
|
||||
|
@ -63,8 +77,7 @@ JX.behavior('aphlict-listen', function(config) {
|
|||
|
||||
// If the notification affected an object on this page, show a
|
||||
// permanent reload notification if we aren't already.
|
||||
if ((response.primaryObjectPHID in config.pageObjects) &&
|
||||
!showing_reload) {
|
||||
if ((response.primaryObjectPHID in config.pageObjects) && !showing_reload) {
|
||||
var reload = new JX.Notification()
|
||||
.setContent('Page updated, click to reload.')
|
||||
.alterClassName('jx-notification-alert', true)
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue