diff --git a/src/containers/ProfileSettingsForm/ProfileSettingsForm.js b/src/containers/ProfileSettingsForm/ProfileSettingsForm.js index 1a71260f..1d15e5ea 100644 --- a/src/containers/ProfileSettingsForm/ProfileSettingsForm.js +++ b/src/containers/ProfileSettingsForm/ProfileSettingsForm.js @@ -5,6 +5,7 @@ import { FormattedMessage, injectIntl, intlShape } from 'react-intl'; import { Field, reduxForm, propTypes as formPropTypes } from 'redux-form'; import classNames from 'classnames'; import { ensureCurrentUser } from '../../util/data'; +import * as propTypes from '../../util/propTypes'; import * as validators from '../../util/validators'; import { isUploadProfileImageOverLimitError } from '../../util/errors'; import { Form, Avatar, Button, ImageFromFile, IconSpinner, TextInputField } from '../../components'; @@ -60,7 +61,7 @@ const RenderAvatar = props => { }; RenderAvatar.defaultProps = { uploadImageError: null }; -const { bool, func, instanceOf, node, object, shape, string } = PropTypes; +const { bool, func, node, object, shape, string } = PropTypes; RenderAvatar.propTypes = { accept: string.isRequired, @@ -73,7 +74,7 @@ RenderAvatar.propTypes = { }).isRequired, label: node.isRequired, type: string.isRequired, - uploadImageError: instanceOf(Error), + uploadImageError: propTypes.error, }; class ProfileSettingsFormComponent extends Component { @@ -293,10 +294,10 @@ ProfileSettingsFormComponent.propTypes = { rootClassName: string, className: string, - uploadImageError: instanceOf(Error), + uploadImageError: propTypes.error, uploadInProgress: bool.isRequired, updateInProgress: bool.isRequired, - updateProfileError: instanceOf(Error), + updateProfileError: propTypes.error, updateProfileReady: bool, // from injectIntl diff --git a/src/containers/ProfileSettingsPage/ProfileSettingsPage.duck.js b/src/containers/ProfileSettingsPage/ProfileSettingsPage.duck.js index 1440460e..ff8c29c9 100644 --- a/src/containers/ProfileSettingsPage/ProfileSettingsPage.duck.js +++ b/src/containers/ProfileSettingsPage/ProfileSettingsPage.duck.js @@ -1,4 +1,5 @@ import { updatedEntities, denormalisedEntities } from '../../util/data'; +import { storableError } from '../../util/errors'; import { currentUserShowSuccess } from '../../ducks/user.duck'; // ================ Action types ================ // @@ -120,7 +121,7 @@ export function uploadImage(actionPayload) { const uploadedImage = resp.data.data; dispatch(uploadImageSuccess({ data: { id, uploadedImage } })); }) - .catch(e => dispatch(uploadImageError({ id, error: e }))); + .catch(e => dispatch(uploadImageError({ id, error: storableError(e) }))); }; } @@ -142,6 +143,6 @@ export const updateProfile = actionPayload => { // Update current user in state.user.currentUser through user.duck.js dispatch(currentUserShowSuccess(currentUser)); }) - .catch(e => dispatch(updateProfileError(e))); + .catch(e => dispatch(updateProfileError(storableError(e)))); }; }; diff --git a/src/containers/ProfileSettingsPage/ProfileSettingsPage.js b/src/containers/ProfileSettingsPage/ProfileSettingsPage.js index 89b9a69f..43291b97 100644 --- a/src/containers/ProfileSettingsPage/ProfileSettingsPage.js +++ b/src/containers/ProfileSettingsPage/ProfileSettingsPage.js @@ -114,10 +114,10 @@ ProfileSettingsPageComponent.defaultProps = { image: null, }; -const { bool, func, instanceOf, object, shape, string } = PropTypes; +const { bool, func, object, shape, string } = PropTypes; ProfileSettingsPageComponent.propTypes = { - authInfoError: instanceOf(Error), + authInfoError: propTypes.error, currentUser: propTypes.currentUser, image: shape({ id: string, @@ -125,14 +125,14 @@ ProfileSettingsPageComponent.propTypes = { file: object, uploadedImage: propTypes.image, }), - logoutError: instanceOf(Error), + logoutError: propTypes.error, onChange: func.isRequired, onImageUpload: func.isRequired, onUpdateProfile: func.isRequired, scrollingDisabled: bool.isRequired, updateInProgress: bool.isRequired, - updateProfileError: instanceOf(Error), - uploadImageError: instanceOf(Error), + updateProfileError: propTypes.error, + uploadImageError: propTypes.error, uploadInProgress: bool.isRequired, };