Next.js Discord

Discord Forum

right way to throw error with server action

Answered
African Slender-snouted Crocodil… posted this in #help-forum
Open in Discord
Avatar
African Slender-snouted CrocodileOP
const loginAction = actionClient
  .schema(loginSchema)
  .action(async ({ parsedInput }) => {
    const supabase = await createClient();
    const { error } = await supabase.auth.signInWithPassword(parsedInput);
    if (error) {
      return { failure: error.message };
    }
    redirect("/dashboard");
  });

so guys i am just asking if this is a good way to throw error using server action

2 Replies