diff --git a/src/index.js b/src/index.js index b5059eb..5d96a88 100644 --- a/src/index.js +++ b/src/index.js @@ -76,7 +76,7 @@ function restoreScroll() { const viewPort = document.body; if (!viewPort) { - console.log('Can not find viewPort element'); + console.log('Can not find viewPort element'); // eslint-disable-line return; } diff --git a/src/pages/profile/ProfilePage.jsx b/src/pages/profile/ProfilePage.jsx index 91dbc87..8748a50 100644 --- a/src/pages/profile/ProfilePage.jsx +++ b/src/pages/profile/ProfilePage.jsx @@ -1,5 +1,7 @@ import React, { Component, PropTypes } from 'react'; +import logger from 'services/logger'; + import { FooterMenu } from 'components/footerMenu'; import styles from './profile.scss'; @@ -79,6 +81,13 @@ export default connect(null, { } }) .then((resp) => !resp.requirePassword || requestPassword(form)) + .catch((resp) => { + if (!resp || !resp.errors) { + logger.warn('Unexpected profile editing error', { + resp + }); + } + }) .finally(() => form.endLoading()); function requestPassword(form) { @@ -88,15 +97,15 @@ export default connect(null, { const onSubmit = () => { form.beginLoading(); sendData() + .then(resolve) + .then(props.onClose) .catch((resp) => { if (resp.errors) { form.setErrors(resp.errors); + } else { + return Promise.reject(resp); } - - return Promise.reject(resp); }) - .then(resolve) - .then(props.onClose) .finally(() => form.endLoading()); }; diff --git a/src/services/logger.js b/src/services/logger.js index 9def95f..bbf4aba 100644 --- a/src/services/logger.js +++ b/src/services/logger.js @@ -23,7 +23,13 @@ const logger = { window.addEventListener('unhandledrejection', (event) => { const error = event.reason || {}; - const message = error.message ? `: ${error.message}` : ''; + + let message = error.message || error; + if (typeof message === 'string') { + message = `: ${message}`; + } else { + message = ''; + } logger.info(`Unhandled rejection${message}`, { error