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

all: remove unnecessary IError() casts

This commit is contained in:
Alexander Medvednikov
2022-10-28 19:08:30 +03:00
parent daa2f90023
commit c6158e4519
28 changed files with 86 additions and 88 deletions

View File

@ -110,10 +110,10 @@ pub fn connect(path string) !DB {
db := &C.sqlite3(0)
code := C.sqlite3_open(&char(path.str), &db)
if code != 0 {
return IError(&SQLError{
return &SQLError{
msg: unsafe { cstring_to_vstring(&char(C.sqlite3_errstr(code))) }
code: code
})
}
}
return DB{
conn: db
@ -129,10 +129,10 @@ pub fn (mut db DB) close() !bool {
if code == 0 {
db.is_open = false
} else {
return IError(&SQLError{
return &SQLError{
msg: unsafe { cstring_to_vstring(&char(C.sqlite3_errstr(code))) }
code: code
})
}
}
return true // successfully closed
}
@ -223,15 +223,15 @@ pub fn (db &DB) exec_one(query string) !Row {
unsafe { rows.free() }
}
if rows.len == 0 {
return IError(&SQLError{
return &SQLError{
msg: 'No rows'
code: code
})
}
} else if code != 101 {
return IError(&SQLError{
return &SQLError{
msg: unsafe { cstring_to_vstring(&char(C.sqlite3_errstr(code))) }
code: code
})
}
}
res := rows[0]
return res