improve readability of server error for user
This commit is contained in:
parent
35c301a686
commit
634f35657e
@ -49,7 +49,20 @@ const EditResourcePage = () => {
|
|||||||
setServerError(undefined);
|
setServerError(undefined);
|
||||||
await router.push(`/resources/${data.id}`);
|
await router.push(`/resources/${data.id}`);
|
||||||
},
|
},
|
||||||
onError: (error) => setServerError(error.message),
|
onError: (error) => {
|
||||||
|
try {
|
||||||
|
const zodErrors = JSON.parse(error.message) as unknown as { message: string }[];
|
||||||
|
setServerError(
|
||||||
|
zodErrors
|
||||||
|
.map((error) => {
|
||||||
|
return error.message;
|
||||||
|
})
|
||||||
|
.join(", ")
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
setServerError(error.message);
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const onSubmit: SubmitHandler<ResourceUpdateInput> = (data) => {
|
const onSubmit: SubmitHandler<ResourceUpdateInput> = (data) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user