Commit f9c8608d388933583c65f43ed6750ec4832159db
Integrates new error stuff into chooseOneResults
Piet Geursen committed on 3/8/2018, 3:27:14 AMParent: 468d684bfde5b5b265ab076477d4c4930e4d8dc8
Files changed
position/sync/chooseOneResults.js | changed |
position/sync/chooseOneResults.js | ||
---|---|---|
@@ -1,6 +1,7 @@ | ||
1 | 1 | const isArray = require('isarray') |
2 | -const {ERROR_POSITION_CHOICE, ERROR_POSITION_TYPE, ERROR_POSITION_LATE} = require('../../types') | |
2 | +const positionChoiceError = require('../../errors/sync/positionChoiceError') | |
3 | +const positionLateError = require('../../errors/sync/positionLateError') | |
3 | 4 | |
4 | 5 | // Expects `poll` and `position` objects passed in to be of shape: |
5 | 6 | // { |
6 | 7 | // key, |
@@ -17,16 +18,14 @@ | ||
17 | 18 | const { author, content } = position.value |
18 | 19 | const { choice } = content.positionDetails |
19 | 20 | |
20 | 21 | if (isInvalidChoice({position, poll})) { |
21 | - // TODO change this to push errors into poll.errors | |
22 | - results.errors.push({type: ERROR_POSITION_CHOICE, position}) | |
22 | + results.errors.push(positionChoiceError({position})) | |
23 | 23 | return results |
24 | 24 | } |
25 | 25 | |
26 | 26 | if (isPositionLate({position, poll})) { |
27 | - // TODO change this to push errors into poll.errors | |
28 | - results.errors.push({type: ERROR_POSITION_LATE, position}) | |
27 | + results.errors.push(positionLateError({position})) | |
29 | 28 | return results |
30 | 29 | } |
31 | 30 | |
32 | 31 | // TODO convert from Array to Object |
Built with git-ssb-web