Evan Kaloudis
7 years ago
4 changed files with 30 additions and 2 deletions
@ -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 |
@ -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('???') |
||||
|
}) |
||||
|
}) |
||||
|
}) |
Loading…
Reference in new issue