Cleanup errors

This commit is contained in:
Matthew Dillon 2015-07-10 16:21:08 -08:00
parent 1ba602b1e2
commit 2ad00f9aa7
2 changed files with 6 additions and 10 deletions

View file

@ -13,10 +13,8 @@ import (
)
var (
ErrSpeciesNotFound = errors.New("Species not found")
ErrSpeciesNotFoundJSON = newJSONError(ErrSpeciesNotFound, http.StatusNotFound)
ErrSpeciesNotUpdated = errors.New("Species not updated")
ErrSpeciesNotUpdatedJSON = newJSONError(ErrSpeciesNotUpdated, http.StatusBadRequest)
ErrSpeciesNotFound = errors.New("Species not found")
ErrSpeciesNotUpdated = errors.New("Species not updated")
)
func init() {
@ -167,7 +165,7 @@ func (s SpeciesService) update(id int64, e *entity, genus string, claims *Claims
return newJSONError(err, http.StatusInternalServerError)
}
if count != 1 {
return ErrSpeciesNotUpdatedJSON
return newJSONError(ErrSpeciesNotUpdated, http.StatusBadRequest)
}
// Reload to send back down the wire

View file

@ -13,10 +13,8 @@ import (
)
var (
ErrStrainNotFound = errors.New("Strain not found")
ErrStrainNotFoundJSON = newJSONError(ErrStrainNotFound, http.StatusNotFound)
ErrStrainNotUpdated = errors.New("Strain not updated")
ErrStrainNotUpdatedJSON = newJSONError(ErrStrainNotUpdated, http.StatusBadRequest)
ErrStrainNotFound = errors.New("Strain not found")
ErrStrainNotUpdated = errors.New("Strain not updated")
)
func init() {
@ -165,7 +163,7 @@ func (s StrainService) update(id int64, e *entity, genus string, claims *Claims)
return newJSONError(err, http.StatusInternalServerError)
}
if count != 1 {
return ErrStrainNotUpdatedJSON
return newJSONError(ErrStrainNotUpdated, http.StatusBadRequest)
}
strain, err := getStrain(id, genus, claims)