From 9ca6c3875503da580d98929a1205cb168316e241 Mon Sep 17 00:00:00 2001 From: Zaiste Date: Wed, 12 May 2021 12:08:12 +0200 Subject: [PATCH] saleor: arrange the error codes --- framework/saleor/utils/throw-user-errors.ts | 22 ++++----------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/framework/saleor/utils/throw-user-errors.ts b/framework/saleor/utils/throw-user-errors.ts index 5488ba282..d0b8a3291 100644 --- a/framework/saleor/utils/throw-user-errors.ts +++ b/framework/saleor/utils/throw-user-errors.ts @@ -1,35 +1,21 @@ import { ValidationError } from '@commerce/utils/errors' -import { - CheckoutErrorCode, - CheckoutUserError, - CustomerErrorCode, - CustomerUserError, -} from '../schema' +import { CheckoutError, CheckoutErrorCode, AppError, AccountError, AccountErrorCode } from '../schema' -export type UserErrors = Array +export type UserErrors = Array export type UserErrorCode = - | CustomerErrorCode | CheckoutErrorCode + | AccountErrorCode | null | undefined -const getCustomMessage = (code: UserErrorCode, message: string) => { - switch (code) { - case 'UNIDENTIFIED_CUSTOMER': - message = 'Cannot find an account that matches the provided credentials' - break - } - return message -} - export const throwUserErrors = (errors?: UserErrors) => { if (errors && errors.length) { throw new ValidationError({ errors: errors.map(({ code, message }) => ({ code: code ?? 'validation_error', - message: getCustomMessage(code, message), + message: message || "", })), }) }