Skip to content

Commit

Permalink
Merge pull request #544 from NASA-IMPACT/fix/779-title-error
Browse files Browse the repository at this point in the history
Get create errors from server
  • Loading branch information
wrynearson authored Sep 25, 2023
2 parents 999920b + befb13c commit b411e36
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 b411e36

Please sign in to comment.