Error handling

Should execute be used to correctly throw errors, or is it the same in this case?
const result = await context.db
.delete(user)
.where(and(eq(user.role, 'student'), eq(user.id, userId)))
.execute();

if (!result.success && result.error) throw new Error(result.error);
const result = await context.db
.delete(user)
.where(and(eq(user.role, 'student'), eq(user.id, userId)))
.execute();

if (!result.success && result.error) throw new Error(result.error);
await context.db
.delete(user)
.where(and(eq(user.role, 'student'), eq(user.id, userId)));
await context.db
.delete(user)
.where(and(eq(user.role, 'student'), eq(user.id, userId)));
1 Reply
predaytor
predaytorOP7mo ago
upd
Want results from more Discord servers?
Add your server