diff --git a/packages/browser-repl/src/components/types/error-output.spec.tsx b/packages/browser-repl/src/components/types/error-output.spec.tsx index 8de218fd34..0a20a4bdb2 100644 --- a/packages/browser-repl/src/components/types/error-output.spec.tsx +++ b/packages/browser-repl/src/components/types/error-output.spec.tsx @@ -3,10 +3,9 @@ import { expect } from '../../../testing/chai'; import { render, mount } from '../../../testing/enzyme'; import { ErrorOutput } from './error-output'; -import type { CodedError } from '@mongosh/types'; describe('ErrorOutput', function () { - class MongoError extends Error implements CodedError { + class MongoError extends Error { code: number; codeName: string; errorInfo: string; diff --git a/packages/browser-repl/src/components/types/error-output.tsx b/packages/browser-repl/src/components/types/error-output.tsx index 243e387da2..2d410a0601 100644 --- a/packages/browser-repl/src/components/types/error-output.tsx +++ b/packages/browser-repl/src/components/types/error-output.tsx @@ -4,7 +4,7 @@ import { isShouldReportAsBugError } from '@mongosh/errors'; import { SimpleTypeOutput } from './simple-type-output'; import { Expandable } from '../utils/expandable'; -import type { CodedError } from '@mongosh/types'; +import type { MongoServerError } from 'mongodb'; interface ErrorOutputProps { value: any; @@ -16,7 +16,7 @@ export class ErrorOutput extends Component { }; renderCollapsed(toggle: () => void): JSX.Element { - const { name, message, codeName } = this.props.value as CodedError; + const { name, message, codeName } = this.props.value as MongoServerError; const formattedName = name + (codeName ? `[${codeName}]` : ''); return (
diff --git a/packages/cli-repl/src/format-output.spec.ts b/packages/cli-repl/src/format-output.spec.ts index b78035c0d6..996c00ade6 100644 --- a/packages/cli-repl/src/format-output.spec.ts +++ b/packages/cli-repl/src/format-output.spec.ts @@ -1,5 +1,4 @@ /* eslint no-control-regex: 0 */ -import type { CodedError } from '@mongosh/types'; import formatRaw from './format-output'; import { expect } from 'chai'; @@ -157,7 +156,7 @@ for (const colors of [false, true]) { }); it('returns name, codeName and message - MongoError', function () { - class MongoError extends Error implements CodedError { + class MongoError extends Error { code: number; codeName: string; constructor( diff --git a/packages/cli-repl/src/format-output.ts b/packages/cli-repl/src/format-output.ts index b348d27aeb..e7cc690d3d 100644 --- a/packages/cli-repl/src/format-output.ts +++ b/packages/cli-repl/src/format-output.ts @@ -9,7 +9,7 @@ import type { CollectionNamesWithTypes, } from '@mongosh/shell-api'; import { isShouldReportAsBugError } from '@mongosh/errors'; -import type { CodedError } from '@mongosh/types'; +import { MongoServerError } from 'mongodb'; type EvaluationResult = { value: any; @@ -252,7 +252,7 @@ export function formatError(error: Error, options: FormatOptions): string { let result = ''; if (error.name) { result += `\r${clr(error.name, 'mongosh:error', options)}`; - const codeName = (error as CodedError).codeName; + const codeName = (error as MongoServerError).codeName; if (codeName) result += `${clr( `[` + (codeName as string) + `]`, diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index bf5c28410c..1ec9990db2 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -619,8 +619,3 @@ export type TimingInterface = { markTime: (category: TimingCategory, label: string) => void; getTimingData: () => [string, string, number][]; }; - -export interface CodedError extends Error { - code?: number; - codeName?: string; -}