Skip to content

Commit

Permalink
fix(core): Use correct error type for email address conflict
Browse files Browse the repository at this point in the history
Closes #299
  • Loading branch information
michaelbromley committed Apr 22, 2020
1 parent e80fcf8 commit 0ba66cb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/core/src/i18n/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"create-fulfillment-orders-must-be-settled": "One or more OrderItems belong to an Order which is in an invalid state",
"create-fulfillment-nothing-to-fulfill": "Nothing to fulfill",
"default-channel-not-found": "Default channel not found",
"email-address-must-be-unique": "The email address must be unique",
"email-address-not-available": "This email address is not available",
"email-address-not-verified": "Please verify this email address before logging in",
"entity-has-no-translation-in-language": "Translatable entity '{ entityName }' has not been translated into the requested language ({ languageCode })",
Expand Down
9 changes: 2 additions & 7 deletions packages/core/src/service/services/customer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ import { ID, PaginatedList } from '@vendure/common/lib/shared-types';
import { Connection } from 'typeorm';

import { RequestContext } from '../../api/common/request-context';
import {
EntityNotFoundError,
IllegalOperationError,
InternalServerError,
UserInputError,
} from '../../common/error/errors';
import { EntityNotFoundError, IllegalOperationError, UserInputError } from '../../common/error/errors';
import { ListQueryOptions } from '../../common/types/common-types';
import { assertFound, idsAreEqual, normalizeEmailAddress } from '../../common/utils';
import { ConfigService } from '../../config/config.service';
Expand Down Expand Up @@ -96,7 +91,7 @@ export class CustomerService {
});

if (existing) {
throw new InternalServerError(`error.email-address-must-be-unique`);
throw new UserInputError(`error.email-address-must-be-unique`);
}
customer.user = await this.userService.createCustomerUser(input.emailAddress, password);

Expand Down

0 comments on commit 0ba66cb

Please sign in to comment.