turms
turms copied to clipboard
Add error handlers for developers to handle internal errors in clients
Motivation
When some internal errors occur (in fact, they're usually errors caused by the custom callbacks provided by developers), there is no way for developers to know the errors have occurred. e.g.
constructor(turmsClient: TurmsClient) {
this._turmsClient = turmsClient;
this._turmsClient.driver
.addNotificationListener(notification => {
const isBusinessNotification = notification.relayedRequest
&& !notification.relayedRequest.createMessageRequest
&& !notification.closeStatus;
if (isBusinessNotification) {
// If "listener(notification.relayedRequest)" throws, developers cannot know it.
this._notificationListeners.forEach(listener => listener(notification.relayedRequest));
}
});
}
so we should provide developers with error handlers for these cases.