import { DatabaseError } from 'pg'
try {
} catch (error: unknown) {
if (
error instanceof DatabaseError && // <-- this does the trick
error.code === '23505' &&
error.constraint === 'user_email_key'
) {
return toError(error)
}
}