Skip to content

Commit

Permalink
made MongoServerError.errorResponse required + casted resulting type …
Browse files Browse the repository at this point in the history
…errors
  • Loading branch information
aditi-khare-mongoDB committed Mar 7, 2024
1 parent 8e33665 commit 2b2f64c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export class MongoError extends Error {
*/
export class MongoServerError extends MongoError {
/** Raw error result document returned by server. */
errorResponse?: ErrorDescription;
errorResponse: ErrorDescription;
codeName?: string;
writeConcernError?: Document;
errInfo?: Document;
Expand Down
6 changes: 3 additions & 3 deletions src/sdam/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class Server extends TypedEventEmitter<ServerEvents> {
this.monitor.on(event, (e: any) => this.emit(event, e));
}

this.monitor.on('resetServer', (error: MongoError) => markServerUnknown(this, error));
this.monitor.on('resetServer', (error: MongoServerError) => markServerUnknown(this, error));
this.monitor.on(Server.SERVER_HEARTBEAT_SUCCEEDED, (event: ServerHeartbeatSucceededEvent) => {
this.emit(
Server.DESCRIPTION_RECEIVED,
Expand Down Expand Up @@ -369,7 +369,7 @@ export class Server extends TypedEventEmitter<ServerEvents> {
// clear for the specific service id.
if (!this.loadBalanced) {
error.addErrorLabel(MongoErrorLabel.ResetPool);
markServerUnknown(this, error);
markServerUnknown(this, error as MongoServerError);
} else if (connection) {
this.pool.clear({ serviceId: connection.serviceId });
}
Expand All @@ -385,7 +385,7 @@ export class Server extends TypedEventEmitter<ServerEvents> {
if (shouldClearPool) {
error.addErrorLabel(MongoErrorLabel.ResetPool);
}
markServerUnknown(this, error);
markServerUnknown(this, error as MongoServerError);
process.nextTick(() => this.requestCheck());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/sdam/topology_description.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export class TopologyDescription {
);

if (descriptionsWithError.length > 0) {
return descriptionsWithError[0].error;
return descriptionsWithError[0].error as MongoServerError;
}

return null;
Expand Down

0 comments on commit 2b2f64c

Please sign in to comment.