Catch the error on trycatch and show the message
Hello, I am throwing a TRPCError inside my procedure
How can I get this
`
throw new TRPCError({
code: "BAD_REQUEST",
message: "Not enough credits",
});throw new TRPCError({
code: "BAD_REQUEST",
message: "Not enough credits",
});How can I get this
messagemessage in my react onSubmitonSubmit handler?async function onSubmit(values: z.infer<typeof formSchema>) {
try {
await createImage({
prompt: values.prompt,
type: values.type,
});
router.refresh();
} catch (cause) {
console.log(cause);
toast({
title: "Error",
description:
"An error occurred while creating your image. Please try again.",
});
}
}async function onSubmit(values: z.infer<typeof formSchema>) {
try {
await createImage({
prompt: values.prompt,
type: values.type,
});
router.refresh();
} catch (cause) {
console.log(cause);
toast({
title: "Error",
description:
"An error occurred while creating your image. Please try again.",
});
}
}