Beau
Beau
SSolidJS
Created by Beau on 12/24/2023 in #support
Is there a way to grab a throwed error in "action" function
Hello i have a question. I'm going more in depth into solid. But is there actually a way to grab the error that has been throwed inside an "action" function? i have a function like this ( example ):
export const register = action(async (data: FormData) => {

const username = data.get("username");
const password = data.get("password");

const repeatPassword = data.get("passwordRepeat");

throw new Error("Not implemented yet");
});
export const register = action(async (data: FormData) => {

const username = data.get("username");
const password = data.get("password");

const repeatPassword = data.get("passwordRepeat");

throw new Error("Not implemented yet");
});
and this is the html / jsx implementation:
<Card
component="form"
class="w-96"
action={register}
method="post"
>
{/** --> show some error here <-- **/}

<input class="border w-full mb-3 rounded-md py-1.5" name="user" type="text" required/>
<input class="border w-full mb-3 rounded-md py-1.5" name="password" type="password" required/>
<input class="border w-full mb-3 rounded-md py-1.5" name="passwordRepeat" type="password"
required/>
<Button class="w-full" component="button" type="submit">
Register
</Button>
</Card>
<Card
component="form"
class="w-96"
action={register}
method="post"
>
{/** --> show some error here <-- **/}

<input class="border w-full mb-3 rounded-md py-1.5" name="user" type="text" required/>
<input class="border w-full mb-3 rounded-md py-1.5" name="password" type="password" required/>
<input class="border w-full mb-3 rounded-md py-1.5" name="passwordRepeat" type="password"
required/>
<Button class="w-full" component="button" type="submit">
Register
</Button>
</Card>
8 replies