print error return traces on error

This commit is contained in:
jaina heartles 2022-12-10 01:29:12 -08:00
parent 522b456939
commit aee81e27b6
2 changed files with 7 additions and 4 deletions

View file

@ -154,8 +154,11 @@ pub fn get(db: anytype, id: Uuid, alloc: std.mem.Allocator) GetError!Actor {
.{id}, .{id},
alloc, alloc,
) catch |err| switch (err) { ) catch |err| switch (err) {
error.NoRows => error.NotFound, error.NoRows => return error.NotFound,
else => error.DatabaseFailure, else => |e| {
std.log.err("{}, {?}", .{ e, @errorReturnTrace() });
return error.DatabaseFailure;
},
}; };
} }

View file

@ -304,8 +304,8 @@ const Row = union(Engine) {
fn get(self: Row, comptime T: type, idx: u15, alloc: ?Allocator) common.GetError!T { fn get(self: Row, comptime T: type, idx: u15, alloc: ?Allocator) common.GetError!T {
if (T == void) return; if (T == void) return;
return switch (self) { return switch (self) {
.postgres => |pg| pg.get(T, idx, alloc), .postgres => |pg| try pg.get(T, idx, alloc),
.sqlite => |lite| lite.get(T, idx, alloc), .sqlite => |lite| try lite.get(T, idx, alloc),
}; };
} }
}; };