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

Add error message middleware #14

Closed
Stevenic opened this issue Jan 26, 2018 · 1 comment
Closed

Add error message middleware #14

Stevenic opened this issue Jan 26, 2018 · 1 comment

Comments

@Stevenic
Copy link
Contributor

This could be done as a sample versus an actual piece of middleware we ship but we need a piece of middleware that you install first in your bot and it listens for an error to be thrown and then simply sends a message to the user telling the something wen't wrong. Other middleware on the stack should have already processed/logged the error so this middleware is just about telling the user something happened.

I think the general strategy we want for all middleware error wise is to handle the error and then re-throw it so someone else can handle it.

In JS I think this middleware looks like:

bot.use({
    contextCreated: (context, next) => {
        return new Promise((resolve, reject) => {
            next().then(
                () => { resolve() },
                (err) => {
                    context.responses.push({ type: 'message', text: `Oops... Something went wrong.`});
                    reject(err);
                }
            );
        });
    }
});
@Stevenic Stevenic changed the title Add error handler middleware Add error message middleware Jan 26, 2018
@Stevenic
Copy link
Contributor Author

Closing this for now as botbuilder-toybox-middleware supports this.

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

1 participant