From c5304aecaca3b29e7b53c04147dd363aeddcb29a Mon Sep 17 00:00:00 2001 From: Thomas Roberts Date: Thu, 11 Apr 2024 11:13:44 +0100 Subject: [PATCH] Convert notices if they are present on error response --- .../assets/js/data/utils/process-error-response.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins/woocommerce-blocks/assets/js/data/utils/process-error-response.ts b/plugins/woocommerce-blocks/assets/js/data/utils/process-error-response.ts index 8e4b425b538..2ab072b08ac 100644 --- a/plugins/woocommerce-blocks/assets/js/data/utils/process-error-response.ts +++ b/plugins/woocommerce-blocks/assets/js/data/utils/process-error-response.ts @@ -13,6 +13,11 @@ import { } from '@woocommerce/types'; import { noticeContexts } from '@woocommerce/base-context/event-emit/utils'; +/** + * Internal dependencies + */ +import { processNotices } from './process-notices'; + type ApiParamError = { param: string; id: string; @@ -195,6 +200,10 @@ export const processErrorResponse = ( return; } + if ( response.data?.notices ) { + processNotices( response.data?.notices ); + } + if ( response.code === 'rest_invalid_param' ) { return processInvalidParamResponse( response, context ); }