1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

tools: fix unhandled error in v new api_test web

This commit is contained in:
Delyan Angelov 2023-07-14 16:19:25 +03:00
parent 9047f7c9a8
commit fb11a16ab8
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -506,10 +506,10 @@ fn (mut app App) service_auth(username string, password string) !string {
users := sql db { users := sql db {
select from User where username == username select from User where username == username
}! }!
user := users.first() if users.len == 0 {
if user.username != username {
return error('user not found') return error('user not found')
} }
user := users.first()
if !user.active { if !user.active {
return error('user is not active') return error('user is not active')
@ -1010,16 +1010,16 @@ fn (mut app App) service_get_user(id int) !User {
println(err) println(err)
return err return err
} }
defer { defer {
db.close() or { panic(err) } db.close() or { panic(err) }
} }
results := sql db { results := sql db {
select from User where id == id select from User where id == id
}! }!
if results.len == 0 {
return results.first() return error('no results')
}
return results[0]
} }
" "
} }