rename folder

This commit is contained in:
Loui Nissen-Petersen
2021-07-16 16:58:03 +02:00
parent 166bb037e4
commit 03dcf96fb1
529 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
import { ValidationError } from '@commerce/utils/errors'
import { CheckoutError, CheckoutErrorCode, AppError, AccountError, AccountErrorCode } from '../schema'
export type UserErrors = Array<CheckoutError | AccountError | AppError>
export type UserErrorCode = CheckoutErrorCode | AccountErrorCode | null | undefined
export const throwUserErrors = (errors?: UserErrors) => {
if (errors && errors.length) {
throw new ValidationError({
errors: errors.map(({ code, message }) => ({
code: code ?? 'validation_error',
message: message || '',
})),
})
}
}
export default throwUserErrors