mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
sqlite: add a sqlite.is_error() helper (#15964)
This commit is contained in:
parent
267e26ba1d
commit
40cbd68272
@ -1,7 +1,7 @@
|
|||||||
module sqlite
|
module sqlite
|
||||||
|
|
||||||
// https://www.sqlite.org/rescode.html
|
// Result represents Sqlite Result and Error Codes
|
||||||
|
// see https://www.sqlite.org/rescode.html
|
||||||
pub enum Result {
|
pub enum Result {
|
||||||
ok = 0
|
ok = 0
|
||||||
error = 1
|
error = 1
|
||||||
@ -107,6 +107,12 @@ pub enum Result {
|
|||||||
ioerr_data = 8202
|
ioerr_data = 8202
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// is_error checks if it is an error code.
|
||||||
pub fn (r Result) is_error() bool {
|
pub fn (r Result) is_error() bool {
|
||||||
return r !in [.ok, .row, .done]
|
return r !in [.ok, .row, .done]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// is_error checks if `code` is an error code.
|
||||||
|
pub fn is_error(code int) bool {
|
||||||
|
return unsafe { Result(code).is_error() }
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user