summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--errors.zig (renamed from error.zig)0
-rw-r--r--sqlite.zig27
2 files changed, 15 insertions, 12 deletions
diff --git a/error.zig b/errors.zig
index cad107b..cad107b 100644
--- a/error.zig
+++ b/errors.zig
diff --git a/sqlite.zig b/sqlite.zig
index d32b402..5aef124 100644
--- a/sqlite.zig
+++ b/sqlite.zig
@@ -9,8 +9,11 @@ pub const c = @cImport({
9 @cInclude("sqlite3.h"); 9 @cInclude("sqlite3.h");
10}); 10});
11 11
12usingnamespace @import("query.zig"); 12const Text = @import("query.zig").Text;
13usingnamespace @import("error.zig"); 13const ParsedQuery = @import("query.zig").ParsedQuery;
14
15const errors = @import("errors.zig");
16const Error = errors.Error;
14 17
15const logger = std.log.scoped(.sqlite); 18const logger = std.log.scoped(.sqlite);
16 19
@@ -72,11 +75,11 @@ pub const Blob = struct {
72 pub fn close(self: *Self) !void { 75 pub fn close(self: *Self) !void {
73 const result = c.sqlite3_blob_close(self.handle); 76 const result = c.sqlite3_blob_close(self.handle);
74 if (result != c.SQLITE_OK) { 77 if (result != c.SQLITE_OK) {
75 return errorFromResultCode(result); 78 return errors.errorFromResultCode(result);
76 } 79 }
77 } 80 }
78 81
79 pub const Reader = io.Reader(*Self, Error, read); 82 pub const Reader = io.Reader(*Self, errors.Error, read);
80 83
81 /// reader returns a io.Reader. 84 /// reader returns a io.Reader.
82 pub fn reader(self: *Self) Reader { 85 pub fn reader(self: *Self) Reader {
@@ -100,7 +103,7 @@ pub const Blob = struct {
100 self.offset, 103 self.offset,
101 ); 104 );
102 if (result != c.SQLITE_OK) { 105 if (result != c.SQLITE_OK) {
103 return errorFromResultCode(result); 106 return errors.errorFromResultCode(result);
104 } 107 }
105 108
106 self.offset += @intCast(c_int, tmp_buffer.len); 109 self.offset += @intCast(c_int, tmp_buffer.len);
@@ -123,7 +126,7 @@ pub const Blob = struct {
123 self.offset, 126 self.offset,
124 ); 127 );
125 if (result != c.SQLITE_OK) { 128 if (result != c.SQLITE_OK) {
126 return errorFromResultCode(result); 129 return errors.errorFromResultCode(result);
127 } 130 }
128 131
129 self.offset += @intCast(c_int, data.len); 132 self.offset += @intCast(c_int, data.len);
@@ -352,7 +355,7 @@ pub const Db = struct {
352 } else { 355 } else {
353 diags.err = getDetailedErrorFromResultCode(result); 356 diags.err = getDetailedErrorFromResultCode(result);
354 } 357 }
355 return errorFromResultCode(result); 358 return errors.errorFromResultCode(result);
356 } 359 }
357 360
358 return Self{ .db = db.? }; 361 return Self{ .db = db.? };
@@ -370,7 +373,7 @@ pub const Db = struct {
370 } else { 373 } else {
371 diags.err = getDetailedErrorFromResultCode(result); 374 diags.err = getDetailedErrorFromResultCode(result);
372 } 375 }
373 return errorFromResultCode(result); 376 return errors.errorFromResultCode(result);
374 } 377 }
375 378
376 return Self{ .db = db.? }; 379 return Self{ .db = db.? };
@@ -579,7 +582,7 @@ pub fn Iterator(comptime Type: type) type {
579 } 582 }
580 if (result != c.SQLITE_ROW) { 583 if (result != c.SQLITE_ROW) {
581 diags.err = getLastDetailedErrorFromDb(self.db); 584 diags.err = getLastDetailedErrorFromDb(self.db);
582 return errorFromResultCode(result); 585 return errors.errorFromResultCode(result);
583 } 586 }
584 587
585 const columns = c.sqlite3_column_count(self.stmt); 588 const columns = c.sqlite3_column_count(self.stmt);
@@ -637,7 +640,7 @@ pub fn Iterator(comptime Type: type) type {
637 } 640 }
638 if (result != c.SQLITE_ROW) { 641 if (result != c.SQLITE_ROW) {
639 diags.err = getLastDetailedErrorFromDb(self.db); 642 diags.err = getLastDetailedErrorFromDb(self.db);
640 return errorFromResultCode(result); 643 return errors.errorFromResultCode(result);
641 } 644 }
642 645
643 const columns = c.sqlite3_column_count(self.stmt); 646 const columns = c.sqlite3_column_count(self.stmt);
@@ -1022,7 +1025,7 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: ParsedQuery) t
1022 ); 1025 );
1023 if (result != c.SQLITE_OK) { 1026 if (result != c.SQLITE_OK) {
1024 diags.err = getLastDetailedErrorFromDb(db.db); 1027 diags.err = getLastDetailedErrorFromDb(db.db);
1025 return errorFromResultCode(result); 1028 return errors.errorFromResultCode(result);
1026 } 1029 }
1027 break :blk tmp.?; 1030 break :blk tmp.?;
1028 }; 1031 };
@@ -1181,7 +1184,7 @@ pub fn Statement(comptime opts: StatementOptions, comptime query: ParsedQuery) t
1181 c.SQLITE_DONE => {}, 1184 c.SQLITE_DONE => {},
1182 else => { 1185 else => {
1183 diags.err = getLastDetailedErrorFromDb(self.db); 1186 diags.err = getLastDetailedErrorFromDb(self.db);
1184 return errorFromResultCode(result); 1187 return errors.errorFromResultCode(result);
1185 }, 1188 },
1186 } 1189 }
1187 } 1190 }