DEV Community

Suli
Suli

Posted on

Clean error handling for async operations in Node.js with Express & Drizzle ORM

What's the best way to handle any database errors in this following snippet:

export async function signupService(username: string, email: string, password: string) {
    const passwordHash = await bcrypt.hash(password, config.saltRounds)
    await db.insert(t.users).values({ username, email, passwordHash })

}
Enter fullscreen mode Exit fullscreen mode

I'm using NodeJS + ExpressJS + DrizzleORM, I would like to know the general best way to handle errors in applications such as this.

Top comments (0)