diff --git a/app/components/GlobalError/GlobalError.js b/app/components/GlobalError/GlobalError.js index d428902041b..0a239147a2a 100644 --- a/app/components/GlobalError/GlobalError.js +++ b/app/components/GlobalError/GlobalError.js @@ -1,6 +1,7 @@ import React from 'react' import PropTypes from 'prop-types' import MdClose from 'react-icons/lib/md/close' +import errorToUserFriendly from 'lib/utils/userFriendlyErrors' import styles from './GlobalError.scss' class GlobalError extends React.Component { @@ -20,7 +21,7 @@ class GlobalError extends React.Component {
-

{error}

+

{errorToUserFriendly(error)}

) diff --git a/app/components/GlobalError/GlobalError.scss b/app/components/GlobalError/GlobalError.scss index d220c14bed3..d748eed6da4 100644 --- a/app/components/GlobalError/GlobalError.scss +++ b/app/components/GlobalError/GlobalError.scss @@ -35,7 +35,8 @@ max-width: 75%; margin-left: auto; margin-right: auto; - font-size: 20px; + font-size: 15px; + line-height: 20px; letter-spacing: 1.5px; font-weight: bold; } diff --git a/app/lib/utils/userFriendlyErrors.js b/app/lib/utils/userFriendlyErrors.js new file mode 100644 index 00000000000..e3347ee18d6 --- /dev/null +++ b/app/lib/utils/userFriendlyErrors.js @@ -0,0 +1,9 @@ +const userFriendlyErrors = { + 'Error: 11 OUT_OF_RANGE: EOF': + "The person you're trying to connect to isn't available or rejected the connection.\ + Their public key may have changed or the server may no longer be responding." +} + +const errorToUserFriendly = error => userFriendlyErrors[error] || error + +export default errorToUserFriendly diff --git a/test/unit/utils/userFriendlyErrors.spec.js b/test/unit/utils/userFriendlyErrors.spec.js new file mode 100644 index 00000000000..62339378f38 --- /dev/null +++ b/test/unit/utils/userFriendlyErrors.spec.js @@ -0,0 +1,17 @@ +import errorToUserFriendly from 'lib/utils/userFriendlyErrors' + +describe('userFriendlyErrors', () => { + describe('errorToUserFriendly', () => { + it('should handle defined user-friendly errors', () => { + expect(errorToUserFriendly('Error: 11 OUT_OF_RANGE: EOF')).toBe( + "The person you're trying to connect to isn't available or rejected the connection.\ + Their public key may have changed or the server may no longer be responding." + ) + }) + + it('should return the original error when there is no user-friendly error conversion', () => { + expect(errorToUserFriendly('Error 12')).toBe('Error 12') + expect(errorToUserFriendly('???')).toBe('???') + }) + }) +})