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

asPromise should be mentioned in error handling documentation #14266

Closed
2 tasks done
auctormaximus opened this issue Jan 18, 2024 · 0 comments
Closed
2 tasks done

asPromise should be mentioned in error handling documentation #14266

auctormaximus opened this issue Jan 18, 2024 · 0 comments
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Milestone

Comments

@auctormaximus
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

asPromise should be mentioned and given an example for in Connection. We are now told to use .catch and await for error handling but this can't be done for createConnection without asPromise which is not mentioned anywhere. There lacks an explanation how to do error handling for createConnection.

Motivation

It took several hours of work just to make simple error handling for createConnection because of the lack of this critical information and because error handling is a basic feature it should not be hidden away in docs/api

Example

Add a line like below or at least mention the need of asPromise in text.

try {
  await mongoose.createConnection('mongodb://127.0.0.1:27017/test').asPromise();
} catch (error) {
  handleError(error);
}
@auctormaximus auctormaximus added enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature new feature This change adds new functionality, like a new method or class labels Jan 18, 2024
@vkarpov15 vkarpov15 added this to the 7.6.9 milestone Jan 18, 2024
@vkarpov15 vkarpov15 added docs This issue is due to a mistake or omission in the mongoosejs.com documentation and removed new feature This change adds new functionality, like a new method or class enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature labels Jan 18, 2024
vkarpov15 added a commit that referenced this issue Feb 20, 2024
vkarpov15 added a commit that referenced this issue Feb 22, 2024
docs(connections): add note about using `asPromise()` with `createConnection()` for error handling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Projects
None yet
Development

No branches or pull requests

2 participants