diff options
author | 6543 <6543@obermui.de> | 2019-12-31 09:21:21 +0100 |
---|---|---|
committer | techknowlogick <techknowlogick@gitea.io> | 2019-12-31 03:21:21 -0500 |
commit | 9600c27085df3f895b2128f1b77aa0ce0b57e7f2 (patch) | |
tree | 9dfbbf44126e7c39b77558ec943c8a2b9a717b10 /models/error.go | |
parent | 655aea13a5ad5dd51bcaafd1b96ecce2673f0312 (diff) | |
download | gitea-9600c27085df3f895b2128f1b77aa0ce0b57e7f2.tar.gz gitea-9600c27085df3f895b2128f1b77aa0ce0b57e7f2.zip |
[API] Fix 9544 | return 200 when reaction already exist (#9550)
* add ErrReactionAlreadyExist
* extend CreateReaction
* reaction already exist = 200
* extend FindReactionsOptions
* refactor swagger options/definitions
* fix swagger-validate
* Update models/error.go
Co-Authored-By: zeripath <art27@cantab.net>
* fix test PART1
* extend FindReactionsOptions with UserID option
* catch error on test
* fix test PART2
* format ...
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <matti@mdranta.net>
Diffstat (limited to 'models/error.go')
-rw-r--r-- | models/error.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/models/error.go b/models/error.go index 396d7594c8..f0d5699aad 100644 --- a/models/error.go +++ b/models/error.go @@ -1201,6 +1201,21 @@ func (err ErrForbiddenIssueReaction) Error() string { return fmt.Sprintf("'%s' is not an allowed reaction", err.Reaction) } +// ErrReactionAlreadyExist is used when a existing reaction was try to created +type ErrReactionAlreadyExist struct { + Reaction string +} + +// IsErrReactionAlreadyExist checks if an error is a ErrReactionAlreadyExist. +func IsErrReactionAlreadyExist(err error) bool { + _, ok := err.(ErrReactionAlreadyExist) + return ok +} + +func (err ErrReactionAlreadyExist) Error() string { + return fmt.Sprintf("reaction '%s' already exists", err.Reaction) +} + // __________ .__ .__ __________ __ // \______ \__ __| | | |\______ \ ____ ________ __ ____ _______/ |_ // | ___/ | \ | | | | _// __ \/ ____/ | \_/ __ \ / ___/\ __\ |