Skip to content

Commit

Permalink
fix: del InternalServerError
Browse files Browse the repository at this point in the history
  • Loading branch information
mansaj committed Jul 31, 2024
1 parent 8e9987f commit 3920d7c
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 28 deletions.
3 changes: 1 addition & 2 deletions src/db/tables/emailAddresses.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 */
Expand Down
3 changes: 1 addition & 2 deletions src/e2e/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -79,7 +78,7 @@ export const getVerificationCode = async (
attempts = 10,
): Promise<string> => {
if (attempts === 0) {
throw new InternalServerError("Unable to retrieve restmail data");
throw new Error("Unable to retrieve restmail data");
}

const context = await request.newContext();
Expand Down
8 changes: 0 additions & 8 deletions src/utils/error.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
MethodNotAllowedError,
ConflictError,
TooManyRequestsError,
InternalServerError
} from './error'

test('BadRequestError', () => {
Expand Down Expand Up @@ -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");
})
14 changes: 0 additions & 14 deletions src/utils/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,11 @@ 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,
ForbiddenError,
MethodNotAllowedError,
ConflictError,
TooManyRequestsError,
InternalServerError,
};
3 changes: 1 addition & 2 deletions src/utils/fluent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3920d7c

Please sign in to comment.