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

Global error #52

Open
bdelville opened this issue Apr 9, 2018 · 1 comment
Open

Global error #52

bdelville opened this issue Apr 9, 2018 · 1 comment

Comments

@bdelville
Copy link

This is a open discussion about a particular line of code of the library:

beautify(
                error, collection, values,
                messages, options.defaultMessage
            )
                .then(next)
                .catch(function (beautifyError) {
                    setTimeout(function () {
                        throw new Error(
                            'mongoose-beautiful-unique-validation error: '
                            + beautifyError.stack
                        );
                    });
});

When beautify fails, its send a global error within a setTimeout() instead of propagating the error. Which lead to a crash.

Is this feature strongly required by this library, or should we just call next(aNewError) like this?

beautify(
                error, collection, values,
                messages, options.defaultMessage
            )
                .then(next)
                .catch((beautifyError) => next(beautifyError) );
});
@bdelville
Copy link
Author

Closing this and proposing a pull-request instead

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