Skip to content

Commit

Permalink
add additional error handling while fetching data, remove infinite lo…
Browse files Browse the repository at this point in the history
…ading spinner
  • Loading branch information
fritz-astronomer committed May 23, 2024
1 parent d2853db commit 192a95a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions astronomer_starship/src/State.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export const reducer = (state, action) => {
return action.error.response.status === 401 ? {
...state,
variablesError: action.error,
variablesLoading: false,
isSetupComplete: false,
isTokenTouched: false,
token: null,
Expand Down Expand Up @@ -183,6 +184,7 @@ export const reducer = (state, action) => {
return action.error.response.status === 401 ? {
...state,
connectionsError: action.error,
connectionsLoading: false,
isSetupComplete: false,
isTokenTouched: false,
token: null,
Expand Down Expand Up @@ -211,6 +213,7 @@ export const reducer = (state, action) => {
return action.error.response.status === 401 ? {
...state,
poolsError: action.error,
poolsLoading: false,
isSetupComplete: false,
isTokenTouched: false,
token: null,
Expand Down Expand Up @@ -241,6 +244,7 @@ export const reducer = (state, action) => {
return action.error.response.status === 401 ? {
...state,
envError: action.error,
envLoading: false,
isSetupComplete: false,
isTokenTouched: false,
token: null,
Expand All @@ -267,6 +271,7 @@ export const reducer = (state, action) => {
return action.error.response.status === 401 ? {
...state,
dagsError: action.error,
dagsLoading: false,
isSetupComplete: false,
isTokenTouched: false,
token: null,
Expand Down
11 changes: 10 additions & 1 deletion astronomer_starship/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,16 @@ export function fetchData(
.then((res) => {
axios
.get(proxyUrl(remoteRouteUrl), { headers: proxyHeaders(token) })
.then((rRes) => dataDispatch(res, rRes)) // , dispatch))
.then((rRes) => {
if (
res.status === 200 && res.headers['content-type'] === 'application/json' &&
rRes.status === 200 && res.headers['content-type'] === 'application/json'
){
dataDispatch(res, rRes)
} else {
errorDispatch('Invalid response');
}
}) // , dispatch))
.catch((err) => errorDispatch(err)); // , dispatch));
})
.catch((err) => errorDispatch(err)); // , dispatch));
Expand Down

0 comments on commit 192a95a

Please sign in to comment.