Catch all exceptions raised in commands that are invoked locally
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
## In development
|
||||||
|
### Bugfixes
|
||||||
|
- `executeFor` functions will no longer fail with an exception if a function scheduled to be called by the local user throws.
|
||||||
|
|
||||||
|
|
||||||
## 1.0.2
|
## 1.0.2
|
||||||
### New API endpoints
|
### New API endpoints
|
||||||
- Added `executeForOthers` and `executeForOtherGMs` that execute for all users/all GMs except the local client.
|
- Added `executeForOthers` and `executeForOtherGMs` that execute for all users/all GMs except the local client.
|
||||||
|
|||||||
@@ -109,9 +109,14 @@ class SocketlibSocket {
|
|||||||
async executeForAllGMs(handler, ...args) {
|
async executeForAllGMs(handler, ...args) {
|
||||||
const [name, func] = this._resolveFunction(handler);
|
const [name, func] = this._resolveFunction(handler);
|
||||||
this._sendCommand(name, args, RECIPIENT_TYPES.ALL_GMS);
|
this._sendCommand(name, args, RECIPIENT_TYPES.ALL_GMS);
|
||||||
if (game.user.isGM)
|
if (game.user.isGM) {
|
||||||
// TODO Make this function call run async, even if the function isn't delcared as async to prevent exceptions to propagate through executeForUsers
|
try {
|
||||||
func(...args);
|
func(...args);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async executeForOtherGMs(handler, ...args) {
|
async executeForOtherGMs(handler, ...args) {
|
||||||
@@ -122,8 +127,11 @@ class SocketlibSocket {
|
|||||||
async executeForEveryone(handler, ...args) {
|
async executeForEveryone(handler, ...args) {
|
||||||
const [name, func] = this._resolveFunction(handler);
|
const [name, func] = this._resolveFunction(handler);
|
||||||
this._sendCommand(name, args, RECIPIENT_TYPES.EVERYONE);
|
this._sendCommand(name, args, RECIPIENT_TYPES.EVERYONE);
|
||||||
// TODO Make this function call run async, even if the function isn't delcared as async to prevent exceptions to propagate through executeForUsers
|
try {
|
||||||
func(...args);
|
func(...args);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async executeForOthers(handler, ...args) {
|
async executeForOthers(handler, ...args) {
|
||||||
@@ -139,9 +147,14 @@ class SocketlibSocket {
|
|||||||
if (currentUserIndex >= 0)
|
if (currentUserIndex >= 0)
|
||||||
recipients.splice(currentUserIndex, 1);
|
recipients.splice(currentUserIndex, 1);
|
||||||
this._sendCommand(name, args, recipients);
|
this._sendCommand(name, args, recipients);
|
||||||
if (currentUserIndex >= 0)
|
if (currentUserIndex >= 0) {
|
||||||
// TODO Make this function call run async, even if the function isn't delcared as async to prevent exceptions to propagate through executeForUsers
|
try {
|
||||||
func(...args);
|
func(...args);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_sendRequest(handlerName, args, recipient) {
|
_sendRequest(handlerName, args, recipient) {
|
||||||
|
|||||||
Reference in New Issue
Block a user