[Solved] Unhandled Runtime Error

i am throwing TRPCError from trpc mutation how can I handle it on the client I am getting 1 of 1 Unhandled Error
7 Replies
HAL 9000
HAL 9000OP3y ago
is this because I am runnning in dev ?
Samathingamajig
... you need to provide that actual error and the relevant code
HAL 9000
HAL 9000OP3y ago
@Samathingamajig I am basically throwing trpc.TRPCError from mutation router how should I handle it in the client side?
HAL 9000
HAL 9000OP3y ago
Samathingamajig
wrap the mutation call in a try { } catch {}
HAL 9000
HAL 9000OP3y ago
<Button
pill={true}
outline={true}
color="gray"
size="sm"
onClick={() => {
try {
assignPotToUser({
poteNumber,
});
} catch (error) {
console.log("what the F!@#$#");
}
}}
disabled={isLoading_assignToteToPicker}
>
<Button
pill={true}
outline={true}
color="gray"
size="sm"
onClick={() => {
try {
assignPotToUser({
poteNumber,
});
} catch (error) {
console.log("what the F!@#$#");
}
}}
disabled={isLoading_assignToteToPicker}
>
it i already in the try catch block it doesn't catch how ever i do have onError on the trpc.useMutation and it does catch the error but still causes thise Unhandled Runtime Error
const {
mutateAsync: assignPotToUser,
isLoading: isLoading_assignPotToUser,
isError: isError_assignPotToUser,
error: error_assignPotToUser,
isSuccess: isSuccess_assignPotToUser,
} = trpc.useMutation("potes.assignPotToUser", {
retry: 0,
onSuccess: (data) => {
setPotMutationResult(data);
},
onError: (error) => {
console.log(error); // <-------------- Works but still causes Unhandled Runtime Error
}
});
const {
mutateAsync: assignPotToUser,
isLoading: isLoading_assignPotToUser,
isError: isError_assignPotToUser,
error: error_assignPotToUser,
isSuccess: isSuccess_assignPotToUser,
} = trpc.useMutation("potes.assignPotToUser", {
retry: 0,
onSuccess: (data) => {
setPotMutationResult(data);
},
onError: (error) => {
console.log(error); // <-------------- Works but still causes Unhandled Runtime Error
}
});
Oh ok it is because I forgot the await and since it is async mutate
Samathingamajig
yea
Want results from more Discord servers?
Add your server