Errors package
This commit is contained in:
parent
0eec85ed08
commit
a880fdea82
24 changed files with 215 additions and 169 deletions
|
@ -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
|
||||
}
|
||||
|
|
Reference in a new issue