mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
rename folder
This commit is contained in:
20
providers/saleor/utils/throw-user-errors.ts
Normal file
20
providers/saleor/utils/throw-user-errors.ts
Normal 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
|
Reference in New Issue
Block a user