Title: Support for handling resolution errors for Editor data module
Author: Adam Zieliński
Published: May 3, 2022

---

 [  ](https://profiles.wordpress.org/zieladam/) [Adam Zieliński](https://profiles.wordpress.org/zieladam/)
8:49 am _on_ May 3, 2022     
Tags: [6.0 ( 76 )](https://make.wordpress.org/core/tag/6-0/),
[dev-notes ( 647 )](https://make.wordpress.org/core/tag/dev-notes/), [dev-notes-6.0 ( 20 )](https://make.wordpress.org/core/tag/dev-notes-6-0/)

# Support for handling resolution errors for Editor data module

WordPress 6.0 no longer ignores the exceptions thrown by the [resolvers](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-data/#resolvers).

In WordPress 5.9 and earlier, an exception thrown inside the resolver kept it in
the resolving state forever. It never got marked as finished. In WordPress 6.0, 
the resolver state is set to error and the exception is re-thrown. This backwards
compatibility-breaking change affects both resolvers from newly registered stores
and the resolvers from the WordPress stores, e.g. the getEntityRecord resolver from
the coreCore Core is the set of software required to run WordPress. The Core Development
Team builds WordPress. store.

**Example:**

Let’s register an example store where the resolver always throws an error:

    ```notranslate
    const temperatureStore = wp.data.createReduxStore( 'my-store', {
        selectors: {
            getTemperature: ( state ) => state.temperature
        },
        resolvers: {
            getTemperature: () => { throw new Error( 'Network error' ); }
        },
        reducer: () => ({}), // Bogus reducer for the example
    } );
    wp.data.registerStore( temperatureStore );
    ```

Using that resolver has different results in different WordPress versions:

**In WordPress 5.9:**

    ```wp-block-code
    const promise = wp.data.resolveSelect( temperatureStore ).getTemperature();
    ```

Error handling is unsupported, so this promise never gets rejected nor resolved.

**In WordPress 6.0:**

    ```wp-block-code
    const promise = wp.data.resolveSelect( temperatureStore ).getTemperature();
    ```

Error handling is now supported, so this promise gets rejected with Error( ‘Networknetwork(
versus site, blog) error’ )

The error details may be retrieved using the `hasLastResolutionFailed`, `getLastResolutionFailure`,
and `getResolutionState` metaMeta Meta is a term that refers to the inside workings
of a group. For us, this is the team that works on internal WordPress sites like
WordCamp Central and Make WordPress.-selectors available on every registered store:

    ```notranslate
    wp.data.select( temperatureStore ).hasResolutionFailed( 'getTemperature' );
    // the above returns: true

    wp.data.select( temperatureStore ).getResolutionError( 'getTemperature' );
    // the above returns: Error( 'Network error' )

    wp.data.select( temperatureStore ).getResolutionState( 'getTemperature' );
    // the above returns: { "state": "error", "error": Error( 'Network error' ) }
    ```

The state returned by `getResolutionState` is one of: “resolving”, “finished”, “
error”, undefined. The undefined indicates that the resolver hasn’t been triggered
yet.

PRs [#38669](https://github.com/WordPress/gutenberg/pull/38669) [#39317](https://github.com/WordPress/gutenberg/pull/39317)

[#6-0](https://make.wordpress.org/core/tag/6-0/), [#dev-notes](https://make.wordpress.org/core/tag/dev-notes/),
[#dev-notes-6-0](https://make.wordpress.org/core/tag/dev-notes-6-0/)

### Share this:

 * [  Threads ](https://make.wordpress.org/core/2022/05/03/support-for-handling-resolution-errors-for-editor-data-module/?share=threads)
 * [  Mastodon ](https://make.wordpress.org/core/2022/05/03/support-for-handling-resolution-errors-for-editor-data-module/?share=mastodon)
 * [  Bluesky ](https://make.wordpress.org/core/2022/05/03/support-for-handling-resolution-errors-for-editor-data-module/?share=bluesky)
 * [  X ](https://make.wordpress.org/core/2022/05/03/support-for-handling-resolution-errors-for-editor-data-module/?share=x)
 * [  Facebook ](https://make.wordpress.org/core/2022/05/03/support-for-handling-resolution-errors-for-editor-data-module/?share=facebook)
 * [  LinkedIn ](https://make.wordpress.org/core/2022/05/03/support-for-handling-resolution-errors-for-editor-data-module/?share=linkedin)

# Post navigation

[← A Week in Core – May 2, 2022](https://make.wordpress.org/core/2022/05/03/a-week-in-core-may-2-2022/)

[Block markup updates for image, quote, list and group blocks →](https://make.wordpress.org/core/2022/05/03/block-markup-updates-for-image-quote-list-and-group-blocks/)