Skip to content

Commit 8f1f572

Browse files
committed
Add unknown error constant
1 parent d4adfce commit 8f1f572

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

projects/packages/forms/src/store/config/reducer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { __ } from '@wordpress/i18n';
1+
import { UNKNOWN_ERROR_MESSAGE } from '../constants';
22
import {
33
RECEIVE_CONFIG,
44
RECEIVE_CONFIG_VALUE,
@@ -36,7 +36,7 @@ export default function reducer(
3636
return {
3737
...state,
3838
isLoading: false,
39-
error: action.error ?? __( 'Unknown error', 'jetpack-forms' ),
39+
error: action.error ?? UNKNOWN_ERROR_MESSAGE,
4040
};
4141
case RECEIVE_CONFIG:
4242
return {

projects/packages/forms/src/store/config/resolvers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import apiFetch from '@wordpress/api-fetch';
2-
import { __ } from '@wordpress/i18n';
2+
import { UNKNOWN_ERROR_MESSAGE } from '../constants';
33
import { INVALIDATE_CONFIG } from './action-types';
44
import { receiveConfig, setConfigError, setConfigLoading } from './actions';
55
import type { ConfigAction, ConfigState } from './types';
@@ -13,7 +13,7 @@ const fetchConfigData = async ( dispatch: ( action: ConfigAction ) => void ) =>
1313
} );
1414
dispatch( receiveConfig( result ) );
1515
} catch ( e ) {
16-
const message = e instanceof Error ? e.message : __( 'Unknown error', 'jetpack-forms' );
16+
const message = e instanceof Error ? e.message : UNKNOWN_ERROR_MESSAGE;
1717
dispatch( setConfigError( message ) );
1818
} finally {
1919
dispatch( setConfigLoading( false ) );
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { __ } from '@wordpress/i18n';
2+
3+
const UNKNOWN_ERROR_MESSAGE = __( 'Unknown error', 'jetpack-forms' );
4+
export { UNKNOWN_ERROR_MESSAGE };

projects/packages/forms/src/store/integrations/reducer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { __ } from '@wordpress/i18n';
1+
import { UNKNOWN_ERROR_MESSAGE } from '../constants';
22
import {
33
RECEIVE_INTEGRATIONS,
44
INVALIDATE_INTEGRATIONS,
@@ -35,7 +35,7 @@ export default function reducer(
3535
return {
3636
...state,
3737
isLoading: false,
38-
error: action.error ?? __( 'Unknown error', 'jetpack-forms' ),
38+
error: action.error ?? UNKNOWN_ERROR_MESSAGE,
3939
};
4040
case RECEIVE_INTEGRATIONS:
4141
return {

projects/packages/forms/src/store/integrations/resolvers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import apiFetch from '@wordpress/api-fetch';
2-
import { __ } from '@wordpress/i18n';
32
import { addQueryArgs } from '@wordpress/url';
3+
import { UNKNOWN_ERROR_MESSAGE } from '../constants';
44
import { INVALIDATE_INTEGRATIONS } from './action-types';
55
import { receiveIntegrations, setIntegrationsError, setIntegrationsLoading } from './actions';
66
import type { IntegrationsAction } from './types';
@@ -15,7 +15,7 @@ export const getIntegrations =
1515
const result = await apiFetch< Integration[] >( { path } );
1616
dispatch( receiveIntegrations( result ) );
1717
} catch ( e ) {
18-
const message = e instanceof Error ? e.message : __( 'Unknown error', 'jetpack-forms' );
18+
const message = e instanceof Error ? e.message : UNKNOWN_ERROR_MESSAGE;
1919
dispatch( setIntegrationsError( message ) );
2020
} finally {
2121
dispatch( setIntegrationsLoading( false ) );

0 commit comments

Comments
 (0)