use servemux *properly* this time; better error handling for DB gets
This commit is contained in:
parent
a33e6717e0
commit
b7c1d85830
16 changed files with 234 additions and 288 deletions
|
|
@ -23,9 +23,7 @@ func GetAccountByID(db *sqlx.DB, id string) (*model.Account, error) {
|
|||
|
||||
err := db.Get(&account, "SELECT * FROM account WHERE id=$1", id)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "no rows") {
|
||||
return nil, nil
|
||||
}
|
||||
if strings.Contains(err.Error(), "no rows") { return nil, nil }
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
@ -37,9 +35,7 @@ func GetAccountByUsername(db *sqlx.DB, username string) (*model.Account, error)
|
|||
|
||||
err := db.Get(&account, "SELECT * FROM account WHERE username=$1", username)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "no rows") {
|
||||
return nil, nil
|
||||
}
|
||||
if strings.Contains(err.Error(), "no rows") { return nil, nil }
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
@ -51,9 +47,7 @@ func GetAccountByEmail(db *sqlx.DB, email string) (*model.Account, error) {
|
|||
|
||||
err := db.Get(&account, "SELECT * FROM account WHERE email=$1", email)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "no rows") {
|
||||
return nil, nil
|
||||
}
|
||||
if strings.Contains(err.Error(), "no rows") { return nil, nil }
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
@ -67,9 +61,7 @@ func GetAccountBySession(db *sqlx.DB, sessionToken string) (*model.Account, erro
|
|||
|
||||
err := db.Get(&account, "SELECT account.* FROM account JOIN token ON id=account WHERE token=$1", sessionToken)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "no rows") {
|
||||
return nil, nil
|
||||
}
|
||||
if strings.Contains(err.Error(), "no rows") { return nil, nil }
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue