| Total Complexity | 1 |
| Complexity/F | 0 |
| Lines of Code | 37 |
| Function Count | 0 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | import React from 'react' |
||
| 2 | import PropTypes from 'prop-types' |
||
| 3 | |||
| 4 | import Container from './base/ErrorContainer' |
||
| 5 | import Content from './base/ErrorContent' |
||
| 6 | |||
| 7 | import NotFound from 'error/components/NotFound' |
||
| 8 | import InternalServer from 'error/components/InternalServer' |
||
| 9 | import General from 'error/components/General' |
||
| 10 | |||
| 11 | 2 | const Error = ({ error }) => { |
|
| 12 | 3 | return ( |
|
| 13 | <Container> |
||
| 14 | <Content>{renderError(error)}</Content> |
||
| 15 | </Container> |
||
| 16 | ) |
||
| 17 | } |
||
| 18 | |||
| 19 | 2 | const renderError = error => { |
|
| 20 | 3 | const { code, message } = error |
|
| 21 | 4 | switch (code) { |
|
| 22 | case 404: |
||
| 23 | 1 | return <NotFound message={message} /> |
|
| 24 | case 500: |
||
| 25 | 1 | return <InternalServer message={message} /> |
|
| 26 | default: |
||
| 27 | case undefined: |
||
| 28 | 1 | return <General message={error.toString()} /> |
|
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 32 | 2 | Error.propTypes = { |
|
| 33 | error: PropTypes.object |
||
| 34 | } |
||
| 35 | |||
| 36 | export default Error |
||
| 37 |