• Robert Knight's avatar
    Make failed API calls reject with an Error · 7d870583
    Robert Knight authored
    Previously failed API calls from the `store` module were rejected with a
    { status, statusText, data, headers } response object.
    
    This had several problems:
    
     * This violated the convention that promises should be rejected with
       Error or Error-like objects, so callers could not rely on the result
       having a `message` property.
    
     * It was up to each of the callers to translate the result into
       a message suitable for display, which is likely to lead to
       inconsistency.
    
     * Testing the translation of different kinds of failures into
       messages was mixed up in the `<annotation>` component tests.
    
    This commit moves the translation of $http responses to `Error` objects
    into the API client (`store`) module and adds tests.
    7d870583
store-test.js 6.7 KB