Save step errors to editor store
[MAILPOET-4659]
This commit is contained in:
@@ -2,6 +2,7 @@ import apiFetch, { APIFetchOptions } from '@wordpress/api-fetch';
|
||||
import { dispatch, StoreDescriptor } from '@wordpress/data';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { store as noticesStore } from '@wordpress/notices';
|
||||
import { storeName } from './store';
|
||||
import { ApiError } from '../api';
|
||||
|
||||
export const registerApiErrorHandler = (): void =>
|
||||
@@ -16,6 +17,12 @@ export const registerApiErrorHandler = (): void =>
|
||||
} catch (error) {
|
||||
const errorObject = error as ApiError;
|
||||
const status = errorObject.data?.status;
|
||||
const code = errorObject.code;
|
||||
|
||||
if (code === 'mailpoet_automation_workflow_not_valid') {
|
||||
dispatch(storeName).setErrors({ steps: errorObject.data.errors });
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (status && status >= 400 && status < 500) {
|
||||
const message = errorObject.message;
|
||||
|
Reference in New Issue
Block a user