Convert notices if they are present on error response

This commit is contained in:
Thomas Roberts 2024-04-11 11:13:44 +01:00
parent f750fb5238
commit c5304aecac
No known key found for this signature in database
GPG Key ID: 0262BEBCBE336365
1 changed files with 9 additions and 0 deletions

View File

@ -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 );
}