Skip to content

Commit

Permalink
perf: Return MongooseError
Browse files Browse the repository at this point in the history
  • Loading branch information
jiayisheji committed Oct 27, 2022
1 parent fa2491e commit 923ca93
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/interfaces/mongoose-options.interface.ts
Expand Up @@ -9,7 +9,7 @@ export interface MongooseModuleOptions
retryDelay?: number;
connectionName?: string;
connectionFactory?: (connection: any, name: string) => any;
connectionError?: (error: MongooseError) => void;
connectionError?: (error: MongooseError) => MongooseError;
}

export interface MongooseOptionsFactory {
Expand Down
8 changes: 3 additions & 5 deletions lib/mongoose-core.module.ts
Expand Up @@ -68,8 +68,7 @@ export class MongooseCoreModule implements OnApplicationShutdown {
).pipe(
handleRetry(retryAttempts, retryDelay),
catchError((error) => {
mongooseConnectionError(error);
throw error;
throw mongooseConnectionError(error);
}),
),
),
Expand Down Expand Up @@ -107,7 +106,7 @@ export class MongooseCoreModule implements OnApplicationShutdown {
connectionFactory || ((connection) => connection);

const mongooseConnectionError =
connectionError || ((error) => {});
connectionError || ((error) => error);

return await lastValueFrom(
defer(async () =>
Expand All @@ -120,8 +119,7 @@ export class MongooseCoreModule implements OnApplicationShutdown {
).pipe(
handleRetry(retryAttempts, retryDelay),
catchError((error) => {
mongooseConnectionError(error);
throw error;
throw mongooseConnectionError(error);
}),
),
);
Expand Down

0 comments on commit 923ca93

Please sign in to comment.