1
0
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:
kahsa 2022-10-04 16:03:59 +09:00 committed by GitHub
parent 267e26ba1d
commit 40cbd68272
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,7 @@
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 {
ok = 0
error = 1
@ -107,6 +107,12 @@ pub enum Result {
ioerr_data = 8202
}
// is_error checks if it is an error code.
pub fn (r Result) is_error() bool {
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() }
}