Finishing the errors cleanup

This commit is contained in:
Nikola Bjelo committed 2018-10-28 13:21:54 +01:00
1 parent 41ea70838f
commit d2c99cbc8a
2 files changed
+4 -6

No files matched your search

+2 -3
View File
@@ -3,7 +3,7 @@ import {
GraphQLID,
GraphQLString
} from 'graphql'
import { AuthentificationError, DatabaseError } from '../../errors'
import { AuthentificationError, DatabaseError, WrongArgumentsError } from '../../errors'
import { EventType } from '../types'
import { Event } from '../../models'
@@ -37,8 +37,7 @@ const resolve = (parent, { eventDesignator, title, newtitle, description }, cont
}
event.rules[ruleIndex].description = description || event.rules[ruleIndex].description
if (event.rules.some(rule => rule.title === newtitle)) {
// need to add an error message here TODO
resolve(event)
reject(new WrongArgumentsError('There is already a rule using your new title'))
} else {
event.rules[ruleIndex].title = newtitle || event.rules[ruleIndex].title
}
@@ -3,7 +3,7 @@ import {
GraphQLID,
GraphQLString
} from 'graphql'
import { AuthentificationError } from '../../errors'
import { AuthentificationError, WrongArgumentsError } from '../../errors'
import { EventType } from '../types'
import { Event } from '../../models'
@@ -24,8 +24,7 @@ const resolve = (parent, { designator, teamId, botId, releaseId }, context) => {
if (err) reject(err)
else {
if (event.participants.some(participant => participant.teamId === teamId)) {
// need to add an error message here TODO
resolve(event)
reject(new WrongArgumentsError('You are already registred'))
} else {
event.participants.push({
teamId,