Errors package

This commit is contained in:
Matthew Dillon 2015-10-01 14:45:36 -07:00
parent 0eec85ed08
commit a880fdea82
24 changed files with 215 additions and 169 deletions

View file

@ -2,20 +2,15 @@ package models
import (
"database/sql"
"errors"
"fmt"
"strings"
"github.com/thermokarst/bactdb/Godeps/_workspace/src/github.com/jmoiron/modl"
"github.com/thermokarst/bactdb/errors"
"github.com/thermokarst/bactdb/helpers"
"github.com/thermokarst/bactdb/types"
)
var (
ErrSpeciesNotFound = errors.New("Species not found")
ErrSpeciesNotUpdated = errors.New("Species not updated")
)
func init() {
DB.AddTableWithName(SpeciesBase{}, "species").SetKeys(true, "Id")
}
@ -163,7 +158,7 @@ func GetSpecies(id int64, genus string, claims *types.Claims) (*Species, error)
GROUP BY sp.id, g.genus_name;`
if err := DBH.SelectOne(&species, q, genus, id); err != nil {
if err == sql.ErrNoRows {
return nil, ErrSpeciesNotFound
return nil, errors.SpeciesNotFound
}
return nil, err
}