Skip to content

Commit

Permalink
get errors from server
Browse files Browse the repository at this point in the history
  • Loading branch information
kamicut committed Sep 12, 2023
1 parent 90c2911 commit befb13c
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,20 @@ export function useDocumentCreate(title, alias, isPdfType) {
const result = await createAtbd(title, alias, isPdfType);

if (result.error) {
processToast.error(`An error occurred: ${result.error.message}`);
if (result.error.response) {
const { status } = result.error.response;
if (status === 400) {
processToast.error(
`An error occurred: ${result.error.response.data.detail}`
);
} else {
processToast.error(
`An error occurred: ${result.error.response.statusText}`
);
}
} else {
processToast.error(`An error occurred: ${result.error.message}`);
}
} else {
processToast.success('Document successfully created');
// To trigger the modals to open from other pages, we use the history
Expand Down

0 comments on commit befb13c

Please sign in to comment.