Skip to content
Snippets Groups Projects
Commit f7186e21 authored by Alexandru Munteanu's avatar Alexandru Munteanu
Browse files

fix(error-handling): replace default text with error handling parsing

parent a1efe07c
No related branches found
No related tags found
2 merge requests!58Sprint #20 - Goal - Reviewers submit report,!54HIN-971: Reviewer respond to invitation
Showing
with 48 additions and 46 deletions
......@@ -14,6 +14,7 @@ import {
MultiAction,
ItemOverrideAlert,
withFetching,
validators,
withCountries,
} from '../'
......@@ -36,7 +37,7 @@ const InviteReviewers = ({ countries, handleSubmit, reset }) => (
<ValidatedField
component={TextField}
name="email"
validate={[required]}
validate={[required, validators.emailValidator]}
/>
</Item>
<Item mr={2} vertical>
......
......@@ -14,6 +14,7 @@ import {
ActionLink,
SortableList,
withFetching,
handleError,
} from './'
const castToBool = author => ({
......@@ -178,9 +179,7 @@ export default compose(
setFormAuthors(newAuthors)
hideModal()
})
.catch(() => {
setModalError('Something went wrong... Please try again.')
}),
.catch(handleError(setModalError)),
}),
withHandlers({
authorEditorSubmit: ({
......
......@@ -123,10 +123,7 @@ export default compose(
withHandlers({
inviteHandlingEditor: ({ inviteHandlingEditor }) => ({
email = '',
}) => props =>
inviteHandlingEditor(email, props).catch(() => {
props.setModalError('Oops! Something went wrong.')
}),
}) => props => inviteHandlingEditor(email, props),
}),
setDisplayName('AssignHandlingEditor'),
)(AssignHE)
......
......@@ -3,7 +3,6 @@ import { actions } from 'pubsweet-client'
import { ConnectPage } from 'xpub-connect'
import { withJournal } from 'xpub-journal'
import { getFormValues } from 'redux-form'
import { replace } from 'react-router-redux'
import { withRouter } from 'react-router-dom'
import { head, get, isEmpty, isUndefined } from 'lodash'
import {
......@@ -96,7 +95,6 @@ export default compose(
),
}),
{
replace,
getSignedUrl,
clearCustomError,
assignHandlingEditor,
......@@ -256,9 +254,9 @@ export default compose(
history.replace('/')
}
})
.catch(() => {
.catch(err => {
setFetching(false)
setModalError('Something went wrong...')
handleError(setModalError)(err)
})
},
onReviewerResponse: ({
......@@ -285,9 +283,9 @@ export default compose(
history.replace('/')
}
})
.catch(() => {
.catch(err => {
setFetching(false)
setModalError('Something went wrong...')
handleError(setModalError)(err)
})
},
onInviteReviewer: ({ collection, fragment, fetchUpdatedCollection }) => (
......@@ -305,9 +303,9 @@ export default compose(
hideModal()
fetchUpdatedCollection()
})
.catch(() => {
.catch(err => {
setFetching(false)
setModalError('Something went wrong...')
handleError(setModalError)(err)
})
},
onResendReviewerInvite: ({
......@@ -329,9 +327,9 @@ export default compose(
hideModal()
fetchUpdatedCollection()
})
.catch(() => {
.catch(err => {
setFetching(false)
setModalError('Something went wrong...')
handleError(setModalError)(err)
})
},
onRevokeReviewerInvite: ({
......@@ -350,9 +348,9 @@ export default compose(
hideModal()
fetchUpdatedCollection()
})
.catch(() => {
.catch(err => {
setFetching(false)
setModalError('Something went wrong...')
handleError(setModalError)(err)
})
},
}),
......@@ -372,7 +370,6 @@ export default compose(
componentDidMount() {
const {
match,
replace,
history,
location,
setEditorInChief,
......@@ -390,10 +387,10 @@ export default compose(
const fragmentId = match.params.version
const { agree, invitationId } = parseSearchParams(location.search)
if (agree === 'true') {
replace(location.pathname)
history.replace(location.pathname)
reviewerDecision({ invitationId, collectionId, fragmentId })
.then(fetchUpdatedCollection)
.catch(redirectToError(replace))
.catch(redirectToError(history.replace))
}
apiGet(`/users?editorInChief=true`).then(res =>
......
......@@ -8,6 +8,8 @@ import {
debounce,
isBoolean,
} from 'lodash'
import { handleError } from 'pubsweet-component-faraday-ui'
import {
autosaveRequest,
autosaveSuccess,
......@@ -115,10 +117,9 @@ export const onSubmit = (
project: collectionId,
})
})
.catch(e => {
.catch(err => {
hideModal()
dispatch(autosaveFailure(e))
setModalError('Something went wrong.')
handleError(setModalError)(err)
})
},
onCancel: hideModal,
......
......@@ -18,6 +18,7 @@ import {
OpenModal,
Pagination,
ActionLink,
handleError,
withFetching,
withPagination,
} from 'pubsweet-component-faraday-ui'
......@@ -174,9 +175,9 @@ export default compose(
getUsers()
hideModal()
})
.catch(() => {
.catch(err => {
setFetching(false)
setModalError('Something went wrong...')
handleError(setModalError)(err)
})
},
getUserRoles: ({ journal: { roles = {} } }) => user => {
......
import { pick, omit, isBoolean, replace } from 'lodash'
import { handleError } from 'pubsweet-component-faraday-ui'
import { update, create } from 'pubsweet-client/src/helpers/api'
const generatePasswordHash = () =>
......@@ -104,9 +105,9 @@ export const onSubmit = (
getUsers()
hideModal()
})
.catch(e => {
.catch(err => {
setFetching(false)
setModalError('Something went wrong...')
handleError(setModalError)(err)
})
}
return update(`/users/${values.id}`, parseUpdateUser(values))
......@@ -115,8 +116,8 @@ export const onSubmit = (
getUsers()
hideModal()
})
.catch(e => {
.catch(err => {
setFetching(false)
setModalError('Something went wrong...')
handleError(setModalError)(err)
})
}
import React from 'react'
import { get } from 'lodash'
import { connect } from 'react-redux'
import { Button, H2, Spinner } from '@pubsweet/ui'
import { Row, ShadowedBox, Text } from 'pubsweet-component-faraday-ui'
import { compose, lifecycle, withState } from 'recompose'
import { Row, Text, ShadowedBox } from 'pubsweet-component-faraday-ui'
import { parseSearchParams } from '../utils'
import { confirmUser } from '../../redux/users'
......@@ -11,7 +12,6 @@ const loading = `Loading...`
const confirmTitle = `Welcome to Hindawi!`
const confirmSubtitle = `Your account has been successfully confirmed.`
const errorTitle = `Something went wrong...`
const errorSubtitle = `Please try again.`
const ConfirmAccount = ({ message: { title, subtitle }, history }) => (
<ShadowedBox center mt={5}>
......@@ -51,11 +51,15 @@ export default compose(
subtitle: confirmSubtitle,
})
})
.catch(() => {
// errors are still gobbled up by pubsweet
.catch(err => {
const subtitle = get(
JSON.parse(err.response),
'error',
'Oops! Something went wrong!',
)
setConfirmMessage({
title: errorTitle,
subtitle: errorSubtitle,
subtitle,
})
})
}
......
......@@ -11,6 +11,7 @@ import {
Text,
Label,
ShadowedBox,
handleError,
withFetching,
} from 'pubsweet-component-faraday-ui'
......@@ -148,9 +149,9 @@ export default compose(
`/projects/${collectionId}/versions/${fragmentId}/details?agree=${true}&invitationId=${invitationId}`,
)
})
.catch(() => {
.catch(err => {
setFetching(false)
setError('Something went wrong...')
handleError(setError)(err)
})
},
}),
......
......@@ -7,6 +7,7 @@ import {
OpenModal,
ActionLink,
ShadowedBox,
handleError,
withFetching,
} from 'pubsweet-component-faraday-ui'
......@@ -54,9 +55,9 @@ export default compose(
setFetching(false)
hideModal()
})
.catch(() => {
.catch(err => {
setFetching(false)
setModalError('Oops! Something went wrong...')
handleError(setModalError)(err)
})
},
}),
......
......@@ -11,6 +11,7 @@ import {
Text,
ActionLink,
UserProfile,
handleError,
} from 'pubsweet-component-faraday-ui'
import { saveUserDetails } from '../utils'
......@@ -74,9 +75,7 @@ export default compose(
setFetching(false)
toggleEdit()
})
.catch(() => {
setError('Something went wrong... Please try again.')
})
.catch(handleError(setError))
},
unlinkOrcid: ({ user, saveUserDetails }) => ({
hideModal,
......@@ -91,9 +90,9 @@ export default compose(
setFetching(false)
hideModal()
})
.catch(() => {
.catch(err => {
setFetching(false)
setModalError('Something went wrong... Please try again.')
handleError(setModalError)(err)
})
},
}),
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment