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

chore: todo items remove class extension constructor overrides #13178

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/analytics/__tests__/errors/AnalyticsError.test.ts
@@ -0,0 +1,12 @@
import { AnalyticsError } from '../../src/errors/AnalyticsError';

describe('AnalyticsError', () => {
it('works with instanceof operator', () => {
const error = new AnalyticsError({
name: 'TestError',
message: 'message',
});

expect(error instanceof AnalyticsError).toBe(true);
});
});
16 changes: 2 additions & 14 deletions packages/analytics/src/errors/AnalyticsError.ts
@@ -1,21 +1,9 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import {
AmplifyError,
AmplifyErrorParams,
} from '@aws-amplify/core/internals/utils';
import { AmplifyError } from '@aws-amplify/core/internals/utils';

/**
* @internal
*/
export class AnalyticsError extends AmplifyError {
constructor(params: AmplifyErrorParams) {
super(params);

// Hack for making the custom error class work when transpiled to es5
// TODO: Delete the following 2 lines after we change the build target to >= es2015
this.constructor = AnalyticsError;
Object.setPrototypeOf(this, AnalyticsError.prototype);
}
}
export class AnalyticsError extends AmplifyError {}
@@ -0,0 +1,12 @@
import { GraphQLApiError } from '../../../src/utils/errors';

describe('GraphQLApiError', () => {
it('works with instanceof operator', () => {
const error = new GraphQLApiError({
name: 'TestError',
message: 'message',
});

expect(error instanceof GraphQLApiError).toBe(true);
});
});
16 changes: 2 additions & 14 deletions packages/api-graphql/src/utils/errors/GraphQLApiError.ts
@@ -1,21 +1,9 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import {
AmplifyError,
AmplifyErrorParams,
} from '@aws-amplify/core/internals/utils';
import { AmplifyError } from '@aws-amplify/core/internals/utils';

/**
* @internal
*/
export class GraphQLApiError extends AmplifyError {
constructor(params: AmplifyErrorParams) {
super(params);

// Hack for making the custom error class work when transpiled to es5
// TODO: Delete the following 2 lines after we change the build target to >= es2015
this.constructor = GraphQLApiError;
Object.setPrototypeOf(this, GraphQLApiError.prototype);
}
}
export class GraphQLApiError extends AmplifyError {}
12 changes: 12 additions & 0 deletions packages/api-rest/__tests__/errors/CanceledError.test.ts
@@ -0,0 +1,12 @@
import { CanceledError } from '../../src/errors';

describe('CanceledError', () => {
it('works with instanceof operator', () => {
const error = new CanceledError({
name: 'TestError',
message: 'message',
});

expect(error instanceof CanceledError).toBe(true);
});
});
12 changes: 12 additions & 0 deletions packages/api-rest/__tests__/errors/RestApiError.test.ts
@@ -0,0 +1,12 @@
import { RestApiError } from '../../src/errors';

describe('RestApiError', () => {
it('works with instanceof operator', () => {
const error = new RestApiError({
name: 'TestError',
message: 'message',
});

expect(error instanceof RestApiError).toBe(true);
});
});
4 changes: 0 additions & 4 deletions packages/api-rest/src/errors/CanceledError.ts
Expand Up @@ -17,10 +17,6 @@ export class CanceledError extends RestApiError {
message: 'Request is canceled by user',
...params,
});

// TODO: Delete the following 2 lines after we change the build target to >= es2015
this.constructor = CanceledError;
Object.setPrototypeOf(this, CanceledError.prototype);
}
}

Expand Down
12 changes: 2 additions & 10 deletions packages/api-rest/src/errors/RestApiError.ts
@@ -1,14 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import { ApiError, ApiErrorParams } from '@aws-amplify/core/internals/utils';
import { ApiError } from '@aws-amplify/core/internals/utils';

export class RestApiError extends ApiError {
constructor(params: ApiErrorParams) {
super(params);

// TODO: Delete the following 2 lines after we change the build target to >= es2015
this.constructor = RestApiError;
Object.setPrototypeOf(this, RestApiError.prototype);
}
}
export class RestApiError extends ApiError {}
10 changes: 10 additions & 0 deletions packages/auth/__tests__/Error.test.ts
@@ -0,0 +1,10 @@
import { NoUserPoolError } from '../src/Errors';
import { AuthErrorTypes } from '../src/types/Auth';

describe('NoUserPoolError', () => {
it('works with instanceof operator', () => {
const error = new NoUserPoolError(AuthErrorTypes.NoConfig);

expect(error instanceof NoUserPoolError).toBe(true);
});
});
12 changes: 12 additions & 0 deletions packages/auth/__tests__/errors/AuthError.test.ts
@@ -0,0 +1,12 @@
import { AuthError } from '../../src/errors/AuthError';

describe('AuthError', () => {
it('works with instanceof operator', () => {
const error = new AuthError({
name: 'TestError',
message: 'message',
});

expect(error instanceof AuthError).toBe(true);
});
});
10 changes: 0 additions & 10 deletions packages/auth/src/Errors.ts
Expand Up @@ -16,11 +16,6 @@ export class AuthError extends Error {
const { message, log } = authErrorMessages[type];
super(message);

// Hack for making the custom error class work when transpiled to es5
// TODO: Delete the following 2 lines after we change the build target to >= es2015
this.constructor = AuthError;
Object.setPrototypeOf(this, AuthError.prototype);

this.name = 'AuthError';
this.log = log || message;

Expand All @@ -32,11 +27,6 @@ export class NoUserPoolError extends AuthError {
constructor(type: AuthErrorTypes) {
super(type);

// Hack for making the custom error class work when transpiled to es5
// TODO: Delete the following 2 lines after we change the build target to >= es2015
this.constructor = NoUserPoolError;
Object.setPrototypeOf(this, NoUserPoolError.prototype);

this.name = 'NoUserPoolError';
}
}
Expand Down
16 changes: 2 additions & 14 deletions packages/auth/src/errors/AuthError.ts
@@ -1,18 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import {
AmplifyError,
AmplifyErrorParams,
} from '@aws-amplify/core/internals/utils';
import { AmplifyError } from '@aws-amplify/core/internals/utils';

export class AuthError extends AmplifyError {
constructor(params: AmplifyErrorParams) {
super(params);

// Hack for making the custom error class work when transpiled to es5
// TODO: Delete the following 2 lines after we change the build target to >= es2015
this.constructor = AuthError;
Object.setPrototypeOf(this, AuthError.prototype);
}
}
export class AuthError extends AmplifyError {}
12 changes: 12 additions & 0 deletions packages/core/__tests__/errors/APIError.test.ts
@@ -0,0 +1,12 @@
import { ApiError } from '../../src/errors/APIError';

describe('ApiError', () => {
it('works with instanceof operator', () => {
const error = new ApiError({
name: 'TestError',
message: 'message',
});

expect(error instanceof ApiError).toBe(true);
});
});
12 changes: 12 additions & 0 deletions packages/core/__tests__/errors/AmplifyError.test.ts
@@ -0,0 +1,12 @@
import { AmplifyError } from '../../src/errors/AmplifyError';

describe('AmplifyError', () => {
it('works with instanceof operator', () => {
const error = new AmplifyError({
name: 'TestError',
message: 'message',
});

expect(error instanceof AmplifyError).toBe(true);
});
});
4 changes: 0 additions & 4 deletions packages/core/src/errors/APIError.ts
Expand Up @@ -42,10 +42,6 @@ export class ApiError extends AmplifyError {
constructor(params: ApiErrorParams) {
super(params);

// TODO: Delete the following 2 lines after we change the build target to >= es2015
this.constructor = ApiError;
Object.setPrototypeOf(this, ApiError.prototype);

if (params.response) {
this._response = params.response;
}
Expand Down
5 changes: 0 additions & 5 deletions packages/core/src/errors/AmplifyError.ts
Expand Up @@ -25,10 +25,5 @@ export class AmplifyError extends Error {
this.name = name;
this.underlyingError = underlyingError;
this.recoverySuggestion = recoverySuggestion;

// Hack for making the custom error class work when transpiled to es5
// TODO: Delete the following 2 lines after we change the build target to >= es2015
this.constructor = AmplifyError;
Object.setPrototypeOf(this, AmplifyError.prototype);
}
}
@@ -0,0 +1,12 @@
import { InteractionsError } from '../../src/errors/InteractionsError';

describe('InteractionsError', () => {
it('works with instanceof operator', () => {
const error = new InteractionsError({
name: 'TestError',
message: 'message',
});

expect(error instanceof InteractionsError).toBe(true);
});
});
16 changes: 2 additions & 14 deletions packages/interactions/src/errors/InteractionsError.ts
@@ -1,18 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import {
AmplifyError,
AmplifyErrorParams,
} from '@aws-amplify/core/internals/utils';
import { AmplifyError } from '@aws-amplify/core/internals/utils';

export class InteractionsError extends AmplifyError {
constructor(params: AmplifyErrorParams) {
super(params);

// Hack for making the custom error class work when transpiled to es5
// TODO: Delete the following 2 lines after we change the build target to >= es2015
this.constructor = InteractionsError;
Object.setPrototypeOf(this, InteractionsError.prototype);
}
}
export class InteractionsError extends AmplifyError {}
@@ -0,0 +1,12 @@
import { InAppMessagingError } from '../../../src/inAppMessaging/errors/InAppMessagingError';

describe('InAppMessagingError', () => {
it('works with instanceof operator', () => {
const error = new InAppMessagingError({
name: 'TestError',
message: 'message',
});

expect(error instanceof InAppMessagingError).toBe(true);
});
});
@@ -0,0 +1,12 @@
import { PushNotificationError } from '../../../src/pushNotifications/errors/PushNotificationError';

describe('PushNotificationError', () => {
it('works with instanceof operator', () => {
const error = new PushNotificationError({
name: 'TestError',
message: 'message',
});

expect(error instanceof PushNotificationError).toBe(true);
});
});
@@ -1,21 +1,9 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import {
AmplifyError,
AmplifyErrorParams,
} from '@aws-amplify/core/internals/utils';
import { AmplifyError } from '@aws-amplify/core/internals/utils';

/**
* @internal
*/
export class InAppMessagingError extends AmplifyError {
constructor(params: AmplifyErrorParams) {
super(params);

// Hack for making the custom error class work when transpiled to es5
// TODO: Delete the following 2 lines after we change the build target to >= es2015
this.constructor = InAppMessagingError;
Object.setPrototypeOf(this, InAppMessagingError.prototype);
}
}
export class InAppMessagingError extends AmplifyError {}
@@ -1,18 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import {
AmplifyError,
AmplifyErrorParams,
} from '@aws-amplify/core/internals/utils';
import { AmplifyError } from '@aws-amplify/core/internals/utils';

export class PushNotificationError extends AmplifyError {
constructor(params: AmplifyErrorParams) {
super(params);

// Hack for making the custom error class work when transpiled to es5
// TODO: Delete the following 2 lines after we change the build target to >= es2015
this.constructor = PushNotificationError;
Object.setPrototypeOf(this, PushNotificationError.prototype);
}
}
export class PushNotificationError extends AmplifyError {}
12 changes: 12 additions & 0 deletions packages/predictions/__tests__/errors/PredictionsError.test.ts
@@ -0,0 +1,12 @@
import { PredictionsError } from '../../src/errors/PredictionsError';

describe('PredictionsError', () => {
it('works with instanceof operator', () => {
const error = new PredictionsError({
name: 'TestError',
message: 'message',
});

expect(error instanceof PredictionsError).toBe(true);
});
});
15 changes: 2 additions & 13 deletions packages/predictions/src/errors/PredictionsError.ts
@@ -1,16 +1,5 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
import {
AmplifyError,
AmplifyErrorParams,
} from '@aws-amplify/core/internals/utils';
import { AmplifyError } from '@aws-amplify/core/internals/utils';

export class PredictionsError extends AmplifyError {
constructor(params: AmplifyErrorParams) {
super(params);

// TODO: Delete the following 2 lines after we change the build target to >= es2015
this.constructor = PredictionsError;
Object.setPrototypeOf(this, PredictionsError.prototype);
}
}
export class PredictionsError extends AmplifyError {}
12 changes: 12 additions & 0 deletions packages/storage/__tests__/errors/CanceledError.test.ts
@@ -0,0 +1,12 @@
import { CanceledError } from '../../src/errors/CanceledError';

describe('CanceledError', () => {
it('works with instanceof operator', () => {
const error = new CanceledError({
name: 'TestError',
message: 'message',
});

expect(error instanceof CanceledError).toBe(true);
});
});