Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExpiredToken errors should be thrown when calling postActivity #55

Closed
harshithkashyap opened this issue Dec 5, 2017 · 1 comment
Closed

Comments

@harshithkashyap
Copy link

From the following snippet, the ExpiredToken error is resolved as success.

private catchExpiredToken(error: any) {
        return error === errorExpiredToken
        ? Observable.of("retry")
        : Observable.throw(error);
    }

I have the following snippet in my code and the catch block is never reached.

try {
    const messageId = await this.pivbotService.directLine
        .postActivity({
            from: this.from,
            type: 'message',
            text: message
        })
        .toPromise();
    console.log(messageId);
    // Logs text "retry"
} catch (err) {
    // Never reached
    console.error(err);
}

Shouldn't catchExpiredToken method throw error in any case?

@billba
Copy link
Member

billba commented Dec 5, 2017

Most posting errors are nonrecoverable (reposting is not expected to yield different results), and in those cases we throw an error. But if a token is expired a new one can be obtained, and the message can be reposted. So instead of throwing an error here, we mark the message as "retry" so that it can be reposted later. This admittedly an inelegant solution. It's convenient for WebChat, but maybe not so much for other applications.

The way to handle these is to subscribe to connectionStatus$ and handle ConnectionStatus.ExpiredToken.

@billba billba closed this as completed Dec 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants