Show error when json formatting fails

This commit is contained in:
Thomas Nordquist
2019-03-04 17:57:12 +01:00
parent 0dea1f9d19
commit 7e9932de0a

View File

@@ -158,7 +158,9 @@ class Publish extends React.Component<Props, State> {
try { try {
const str = JSON.stringify(JSON.parse(this.props.payload), undefined, ' ') const str = JSON.stringify(JSON.parse(this.props.payload), undefined, ' ')
this.updatePayload(str) this.updatePayload(str)
} catch { } } catch (error) {
this.props.globalActions.showError(`Format error: ${error.message}`)
}
} }
} }
@@ -325,6 +327,7 @@ class Publish extends React.Component<Props, State> {
const mapDispatchToProps = (dispatch: any) => { const mapDispatchToProps = (dispatch: any) => {
return { return {
actions: bindActionCreators(publishActions, dispatch), actions: bindActionCreators(publishActions, dispatch),
globalActions: bindActionCreators(globalActions, dispatch),
} }
} }