Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core-data] Do not suppress errors in the getEntityRecord and getEntityRecords resolvers #39317

Merged
merged 5 commits into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions packages/core-data/src/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ export const getEntityRecord = ( kind, name, key = '', query ) => async ( {

const record = await apiFetch( { path } );
dispatch.receiveEntityRecords( kind, name, record, query );
} catch ( error ) {
// We need a way to handle and access REST API errors in state
// Until then, catching the error ensures the resolver is marked as resolved.
// See similar implementation in `getEntityRecords()`.
} finally {
dispatch.__unstableReleaseStoreLock( lock );
}
Expand Down Expand Up @@ -202,10 +198,6 @@ export const getEntityRecords = ( kind, name, query = {} ) => async ( {
args: resolutionsArgs,
} );
}
} catch ( error ) {
// We need a way to handle and access REST API errors in state
// Until then, catching the error ensures the resolver is marked as resolved.
// See similar implementation in `getEntityRecord()`.
} finally {
dispatch.__unstableReleaseStoreLock( lock );
}
Expand Down
23 changes: 23 additions & 0 deletions packages/editor/src/store/test/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ describe( 'Post actions', () => {
path.startsWith( `/wp/v2/posts/${ postId }` )
) {
return { ...post, ...data };
} else if (
// This URL is requested by the actions dispatched in this test.
// They are safe to ignore and are only listed here to avoid triggeringan error.
method === 'GET' &&
path.startsWith( '/wp/v2/types/post' )
) {
return {};
}

throw {
Expand Down Expand Up @@ -163,6 +170,15 @@ describe( 'Post actions', () => {
} else if ( method === 'GET' ) {
return [];
}
} else if ( method === 'GET' ) {
// These URLs are requested by the actions dispatched in this test.
// They are safe to ignore and are only listed here to avoid triggeringan error.
if (
path.startsWith( '/wp/v2/types/post' ) ||
path.startsWith( `/wp/v2/posts/${ postId }` )
) {
return {};
adamziel marked this conversation as resolved.
Show resolved Hide resolved
}
}

throw {
Expand Down Expand Up @@ -239,6 +255,13 @@ describe( 'Post actions', () => {
...data,
};
}
// This URL is requested by the actions dispatched in this test.
// They are safe to ignore and are only listed here to avoid triggeringan error.
} else if (
method === 'GET' &&
path.startsWith( '/wp/v2/types/post' )
) {
return {};
}

throw {
Expand Down