1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Install an uncaught exception handler in Aphlict

Summary:
Ref T5373. This seems to work pretty much correctly.

Also stop popping bubbles and just use the log, since users find the bubbles confusing/not useful and they're not great for developers either.

Future diffs will expose more user-facing stuff.

Test Plan: Added `throw` to AphlictClient.as, got a log in the parent window.

Reviewers: joshuaspence

Reviewed By: joshuaspence

Subscribers: epriestley

Maniphest Tasks: T5373

Differential Revision: https://secure.phabricator.com/D9698
This commit is contained in:
epriestley 2014-06-23 15:18:36 -07:00
parent 46d9bebc84
commit 80f26e96ea
4 changed files with 15 additions and 17 deletions

View file

@ -34,7 +34,7 @@ package {
ExternalInterface.call('JX.Aphlict.didReceiveEvent', type, object); ExternalInterface.call('JX.Aphlict.didReceiveEvent', type, object);
} }
final protected function error(error:Error):void { final protected function error(error:Object):void {
this.externalInvoke('error', error.toString()); this.externalInvoke('error', error.toString());
} }

View file

@ -4,7 +4,7 @@ package {
import flash.external.ExternalInterface; import flash.external.ExternalInterface;
import flash.utils.Dictionary; import flash.utils.Dictionary;
import flash.utils.Timer; import flash.utils.Timer;
import flash.events.UncaughtErrorEvent;
final public class AphlictClient extends Aphlict { final public class AphlictClient extends Aphlict {
@ -37,6 +37,10 @@ package {
public function AphlictClient() { public function AphlictClient() {
super(); super();
loaderInfo.uncaughtErrorEvents.addEventListener(
UncaughtErrorEvent.UNCAUGHT_ERROR,
this.uncaughtErrorHandler);
ExternalInterface.addCallback('connect', this.externalConnect); ExternalInterface.addCallback('connect', this.externalConnect);
ExternalInterface.call( ExternalInterface.call(
'JX.Stratcom.invoke', 'JX.Stratcom.invoke',
@ -45,6 +49,10 @@ package {
{}); {});
} }
private function uncaughtErrorHandler(event:UncaughtErrorEvent):void {
this.error(event.error.toString());
}
public function externalConnect( public function externalConnect(
server:String, server:String,
port:Number, port:Number,

View file

@ -8,6 +8,7 @@
* javelin-dom * javelin-dom
* javelin-json * javelin-json
* javelin-router * javelin-router
* javelin-util
* phabricator-notification * phabricator-notification
*/ */
@ -54,28 +55,17 @@ JX.behavior('aphlict-listen', function(config) {
// a request to Phabricator to get notification details. // a request to Phabricator to get notification details.
function onaphlictmessage(type, message) { function onaphlictmessage(type, message) {
switch (type) { switch (type) {
case 'error':
new JX.Notification()
.setContent('(Aphlict) ' + message)
.alterClassName('jx-notification-error', true)
.setDuration(0)
.show();
break;
case 'receive': case 'receive':
JX.Stratcom.invoke('aphlict-receive-message', null, message); JX.Stratcom.invoke('aphlict-receive-message', null, message);
break; break;
default: default:
if (__DEV__ && config.debug) { case 'error':
if (config.debug) {
var details = message ? JX.JSON.stringify(message) : ''; var details = message ? JX.JSON.stringify(message) : '';
JX.log('(Aphlict) [' + type + '] ' + details);
new JX.Notification()
.setContent('(Aphlict) [' + type + '] ' + details)
.alterClassName('jx-notification-debug', true)
.setDuration(3000)
.show();
} }
break;
} }
} }

Binary file not shown.