Skip to content

Commit

Permalink
fixed err message and reset data when no data
Browse files Browse the repository at this point in the history
  • Loading branch information
prabh-t committed Oct 12, 2024
1 parent c554b3a commit dc89a45
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/ui/pages/query/QueryPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,22 @@ const QueryPageContent = (props: QueryPageProps) => {
if (mappingResponse.content?.inputs?.length > 0) {
setData(mappingResponse)
} else {
setData(null) // clear prev data
setWarning(NO_RESULT)
}
}
} else {
setData(null) // clear prev data
setWarning(NO_DATA)
}
})
.catch((err) => {
setData(null) // clear prev data
if (err.response) {
if (err.response.status === 404) {
if (err.response.status === 404) { // Not found
setWarning(NO_RESULT);
} else {
setWarning(`Error ${err.response.status}: ${err.response.statusText}`);
setWarning(`Error ${err.response.status}: ${err.message}`);
}
} else {
setWarning(UNEXPECTED_ERR);
Expand Down
7 changes: 5 additions & 2 deletions src/ui/pages/result/ResultPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ function ResultPageContent(props: ResultPageProps) {
setResultTitle(firstInputLine)
}
} else {
setData(null) // clear prev data
setWarning(NO_RESULT)
}
// if no result warning has been set, the following will override it
Expand All @@ -129,15 +130,17 @@ function ResultPageContent(props: ResultPageProps) {
// navigate to last page?
}
} else {
setData(null) // clear prev data
setWarning(NO_DATA)
}
})
.catch((err) => {
setData(null) // clear prev data
if (err.response) {
if (err.response.status === 404) {
if (err.response.status === 404) { // Not found
setWarning(NO_RESULT);
} else {
setWarning(`Error ${err.response.status}: ${err.response.statusText}`);
setWarning(`Error ${err.response.status}: ${err.message}`);
}
} else {
setWarning(UNEXPECTED_ERR);
Expand Down

0 comments on commit dc89a45

Please sign in to comment.