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

feat: Add connection error handle #1550

Merged
merged 5 commits into from
Oct 31, 2022
Merged

Conversation

jiayisheji
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #1247

What is the new behavior?

Described here: #1247

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Comment on lines 71 to 72
mongooseConnectionError(error);
throw error;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mongooseConnectionError(error);
throw error;
throw mongooseConnectionError(error);

what about this approach instead (this in combination with https://github.com/nestjs/mongoose/pull/1550/files#r1003070783)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a very nice suggestion

jiayisheji and others added 2 commits October 27, 2022 09:17
Return MongooseError

Co-authored-by: Kamil Mysliwiec <mail@kamilmysliwiec.com>
@@ -9,6 +9,7 @@ export interface MongooseModuleOptions
retryDelay?: number;
connectionName?: string;
connectionFactory?: (connection: any, name: string) => any;
connectionError?: (error: MongooseError) => MongooseError;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
connectionError?: (error: MongooseError) => MongooseError;
connectionErrorFactory?: (error: MongooseError) => MongooseError;

@kamilmysliwiec
Copy link
Member

lgtm

@kamilmysliwiec kamilmysliwiec merged commit 4fae301 into nestjs:master Oct 31, 2022
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

Successfully merging this pull request may close these issues.

2 participants