1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-16 00:03:45 +00:00

1. Unified uncaughtException exception processing

2. updated promise, so uncaughtRejection emits an uncaughtException
This commit is contained in:
Bryan Roe
2020-02-06 18:57:18 -08:00
parent 937ae3b5d2
commit 5f1656b0ba
3 changed files with 36 additions and 17 deletions

View File

@@ -122,8 +122,15 @@ function Promise(promiseFunc)
this.then = function (resolved, rejected)
{
if (resolved) { this._internal.once('resolved', event_switcher(this, resolved).func); }
if (rejected) { this._internal.once('rejected', event_switcher(this, rejected).func); }
if (rejected)
{
this._internal.once('rejected', event_switcher(this, rejected).func);
}
else
{
this._internal.once('rejected', function (e) { process.emit('uncaughtException', 'promise.unhandledRejection: ' + e); });
}
var retVal = new Promise(function (r, j) { });
this._internal.once('resolved', retVal._internal.resolver);
this._internal.once('rejected', retVal._internal.rejector);