Total Complexity | 2 |
Complexity/F | 1 |
Lines of Code | 26 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Coverage | 100% |
Changes | 0 |
1 | 2 | const errorCodesStatus = [ |
|
2 | { |
||
3 | type: TypeError, |
||
4 | status: 422, |
||
5 | }, |
||
6 | { |
||
7 | type: RangeError, |
||
8 | status: 404, |
||
9 | }, |
||
10 | { |
||
11 | type: Error, |
||
12 | status: 500, |
||
13 | }, |
||
14 | ]; |
||
15 | |||
16 | /** |
||
17 | * Get a http status when you send an error. |
||
18 | * When it is a error, throw back the error. |
||
19 | * |
||
20 | * @param {Error} error |
||
21 | * |
||
22 | * @return {number} |
||
23 | */ |
||
24 | export default (error) => |
||
25 | 13 | errorCodesStatus.find((errorCode) => error instanceof errorCode.type) |
|
26 | .status; |
||
27 |