Skip to content

Commit f025125

Browse files
fix TS issue
1 parent 8f3a175 commit f025125

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

src/operations/execute_operation.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ async function tryOperation<
295295
const result = await server.modernCommand(operation, timeoutContext);
296296
return operation.handleOk(result);
297297
} catch (error) {
298-
operation.handleError(error);
298+
return operation.handleError(error);
299299
}
300300
} catch (operationError) {
301301
if (!(operationError instanceof MongoError)) throw operationError;
@@ -313,8 +313,8 @@ async function tryOperation<
313313
}
314314
}
315315

316-
if (previousOperationError) throw previousOperationError;
317-
318-
// @ts-expect-error asdf
319-
return;
316+
throw (
317+
previousOperationError ??
318+
new MongoRuntimeError('Tried to propagate retryability error, but no error was found.')
319+
);
320320
}

src/operations/operation.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,14 @@ export abstract class ModernizedOperation<TResult> extends AbstractOperation<TRe
144144
throw new Error('cannot execute!!');
145145
}
146146

147+
/**
148+
* Build a raw command document.
149+
*/
147150
abstract buildCommand(connection: Connection, session?: ClientSession): Document;
148151

152+
/**
153+
* Builds an instance of `ServerCommandOptions` to be used for operation execution.
154+
*/
149155
abstract buildOptions(timeoutContext: TimeoutContext): ServerCommandOptions;
150156

151157
/**
@@ -168,10 +174,12 @@ export abstract class ModernizedOperation<TResult> extends AbstractOperation<TRe
168174
}
169175

170176
/**
171-
* Optional - if the operation performs error handling, such as wrapping or renaming the error,
177+
* Optional.
178+
*
179+
* If the operation performs error handling, such as wrapping, renaming the error, or squashing errors
172180
* this method can be overridden.
173181
*/
174-
handleError(error: MongoError): void {
182+
handleError(error: MongoError): TResult | never {
175183
throw error;
176184
}
177185
}

src/operations/search_indexes/drop.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export class DropSearchIndexOperation extends ModernizedOperation<void> {
3636
if (typeof this.name === 'string') {
3737
command.name = this.name;
3838
}
39+
3940
return command;
4041
}
4142

0 commit comments

Comments
 (0)