Skip to content

Commit

Permalink
feat(api): introduce error handling mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
jiridostal committed Oct 9, 2018
1 parent 2f7ed45 commit 91ed4f1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { sCveDetailsPage } from '../../../Store/Selectors/CVESelectors';
import CVEPageDescriptionResolution from '../CVEPageDescriptionResolution/CVEPageDescriptionResolution';
import CVEPageOverview from '../CVEPageOverview/CVEPageOverview';
import propTypes from 'prop-types';
import { dispatchAction } from '../../../Helpers/MiscHelp';

class CVEPageDetails extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -36,7 +37,7 @@ function mapStateToProps(state) {

const mapDispatchToProps = dispatch => {
return {
fetchData: cveName => dispatch(fetchCveDetails(cveName))
fetchData: cveName => dispatchAction(fetchCveDetails(cveName), dispatch)
};
};

Expand Down
3 changes: 3 additions & 0 deletions src/Helpers/MiscHelp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function dispatchAction(actionCreator, dispatch) {
return dispatch(actionCreator).catch(() => {});
}
2 changes: 1 addition & 1 deletion src/Store/Actions/CVEActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ export const fetchCveDetails = synopsis => ({
type: ActionTypes.FETCH_CVE_DETAILS,
payload: new Promise(resolve => {
resolve(CVEHelper.getCveDetails(synopsis));
})
}).then(result => result)
});

0 comments on commit 91ed4f1

Please sign in to comment.