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(NODE-3403): define MongoRuntimeError children #2894

Merged
merged 2 commits into from
Jul 9, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,112 @@ export class MongoRuntimeError extends MongoDriverError {
}
}

/**
* An error generated when a batch command is reexecuted after one of the commands in the batch
* has failed
*
*
* @public
* @category Error
*/
export class MongoBatchReExecutionError extends MongoRuntimeError {
constructor(message: string) {
super(message);
}

get name(): string {
return 'MongoBatchReExecutionError';
}
}

/**
* An Error thrown when the user attempts to operate on a database or collection through a MongoClient
andymina marked this conversation as resolved.
Show resolved Hide resolved
* that has not yet successfully called the "connect" method
*
*
* @public
* @category Error
*/
export class MongoNotConnectedError extends MongoRuntimeError {
constructor(message: string) {
super(message);
}

get name(): string {
return 'MongoNotConnectedError';
}
}

/**
* An error thrown when the user attempts to operate on a cursor that is in a state which does not
* support the attempted operation.
*
*
* @public
* @category Error
*/
export class MongoCursorError extends MongoRuntimeError {
constructor(message: string) {
super(message);
}

get name(): string {
return 'MongoCursorError';
}
}

/**
* An error thrown when the user calls a function or method not supported on a tailable cursor
*
*
* @public
* @category Error
*/
export class MongoTailableCursorError extends MongoCursorError {
constructor(message: string) {
super(message);
}

get name(): string {
return 'MongoTailableCursorError';
}
}

/**
* An error thrown when the user attempts to add options to a cursor that has already been
* initialized
*
*
* @public
* @category Error
*/
export class MongoCursorInUseError extends MongoCursorError {
constructor(message: string) {
super(message);
}

get name(): string {
return 'MongoCursorInUseError';
}
}

/**
* An error thrown when an attempt is made to read from a cursor that has been exhausted
*
*
* @public
* @category Error
*/
export class MongoCursorExhaustedError extends MongoCursorError {
constructor(message: string) {
super(message);
}

get name(): string {
return 'MongoCursorExhaustedError';
}
}

/** @internal */
const kBeforeHandshake = Symbol('beforeHandshake');
export function isNetworkErrorBeforeHandshake(err: MongoNetworkError): boolean {
Expand Down