diff --git a/src/db/tables/emailAddresses.js b/src/db/tables/emailAddresses.js index 627dad8fd12..0536354a256 100644 --- a/src/db/tables/emailAddresses.js +++ b/src/db/tables/emailAddresses.js @@ -9,7 +9,6 @@ import { getSha1 } from '../../utils/fxa' import { getSubscriberByEmail, updateFxAData } from './subscribers.js' import { ForbiddenError, - InternalServerError, UnauthorizedError } from '../../utils/error' import { getMessage } from '../../utils/fluent.js' @@ -203,7 +202,7 @@ async function _addEmailHash (sha1, email, signupLanguage, verified = false) { } catch (e) { // @ts-ignore Log whatever, we don't care console.error(e) - throw new InternalServerError(getMessage('error-could-not-add-email')) + throw new Error(getMessage('error-could-not-add-email')) } } /* c8 ignore stop */ diff --git a/src/e2e/utils/helpers.ts b/src/e2e/utils/helpers.ts index 5f30a396e40..287eafa3045 100644 --- a/src/e2e/utils/helpers.ts +++ b/src/e2e/utils/helpers.ts @@ -3,7 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import { expect, request, Page, Locator, test } from "@playwright/test"; -import { InternalServerError } from "../../utils/error"; import { LandingPage } from "../pages/landingPage.js"; import { AuthPage } from "../pages/authPage.js"; @@ -79,7 +78,7 @@ export const getVerificationCode = async ( attempts = 10, ): Promise => { if (attempts === 0) { - throw new InternalServerError("Unable to retrieve restmail data"); + throw new Error("Unable to retrieve restmail data"); } const context = await request.newContext(); diff --git a/src/utils/error.test.js b/src/utils/error.test.js index 5b60b18d5da..87d9a90ffd2 100644 --- a/src/utils/error.test.js +++ b/src/utils/error.test.js @@ -10,7 +10,6 @@ import { MethodNotAllowedError, ConflictError, TooManyRequestsError, - InternalServerError } from './error' test('BadRequestError', () => { @@ -54,10 +53,3 @@ test('TooManyRequestsError', () => { expect(error.message).toBe(errorMessage); expect(error.name).toBe("Too Many Requests"); }) - -test('InternalServerError', () => { - const errorMessage = 'InternalServerError message' - const error = new InternalServerError(errorMessage) - expect(error.message).toBe(errorMessage); - expect(error.name).toBe("Internal Server Error"); -}) diff --git a/src/utils/error.ts b/src/utils/error.ts index d29495a4c5d..179656ec8cd 100644 --- a/src/utils/error.ts +++ b/src/utils/error.ts @@ -89,19 +89,6 @@ class TooManyRequestsError extends Error { } } -class InternalServerError extends Error { - public statusCode: number; - - constructor(message: MessageType, ...config: ConfigType) { - super(message, ...config); - this.name = "Internal Server Error"; - this.statusCode = 500; - // TODO: Add unit test when changing this code: - /* c8 ignore next */ - this.message = message || genericErrorMessage; - } -} - export { BadRequestError, UnauthorizedError, @@ -109,5 +96,4 @@ export { MethodNotAllowedError, ConflictError, TooManyRequestsError, - InternalServerError, }; diff --git a/src/utils/fluent.js b/src/utils/fluent.js index d71a452ba2e..52e13455b10 100644 --- a/src/utils/fluent.js +++ b/src/utils/fluent.js @@ -9,7 +9,6 @@ import { FluentBundle, FluentResource } from '@fluent/bundle' import { negotiateLanguages } from '@fluent/langneg' import AppConstants from '../appConstants.js' import { localStorage } from './localStorage' -import { InternalServerError } from '../utils/error' // This file will be removed once we've fully switched to React /* c8 ignore start */ @@ -37,7 +36,7 @@ async function initFluentBundles () { })) } catch (/** @type {any} */ e) { console.error('Could not read Fluent file:', e) - throw new InternalServerError(e) + throw new Error(e) } fluentBundles[locale] = bundle