turms icon indicating copy to clipboard operation
turms copied to clipboard

Add error handlers for developers to handle internal errors in clients

Open JamesChenX opened this issue 4 years ago • 1 comments

JamesChenX avatar Oct 09 '21 07:10 JamesChenX

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.

JamesChenX avatar Oct 09 '21 07:10 JamesChenX