Update error notification on 404 when fetching JSON feed

pull/10616/head
Jared Scheib 2017-06-13 19:21:57 -07:00
parent 9e38616783
commit f8754fb3d2
1 changed files with 12 additions and 3 deletions

View File

@ -4,6 +4,8 @@ import {errorThrown} from 'shared/actions/errors'
import * as actionTypes from 'src/status/constants/actionTypes'
import {HTTP_NOT_FOUND} from 'shared/constants'
const fetchJSONFeedRequested = () => ({
type: actionTypes.FETCH_JSON_FEED_REQUESTED,
})
@ -25,8 +27,15 @@ export const fetchJSONFeedAsync = url => async dispatch => {
} catch (error) {
console.error(error)
dispatch(fetchJSONFeedFailed())
dispatch(
errorThrown(error, `Failed to fetch NewsFeed: ${error.data.message}`)
)
if (error.status === HTTP_NOT_FOUND) {
dispatch(
errorThrown(
error,
`Failed to fetch News Feed. JSON Feed at '${url}' returned 404 (Not Found)`
)
)
} else {
dispatch(errorThrown(error, 'Failed to fetch NewsFeed'))
}
}
}