Skip to content

Commit

Permalink
Report Data API HTTP timeout errors as dataset server errors on repor…
Browse files Browse the repository at this point in the history
…t pages.
  • Loading branch information
cstephen authored and BobTorgerson committed Jan 27, 2025
1 parent 7de78c9 commit 55dcde9
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 9 deletions.
8 changes: 7 additions & 1 deletion store/beetle.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ export const actions = {
context.rootGetters['place/urlFragment']()
let expectedDataKeys = ['1988-2017', '2010-2039', '2040-2069', '2070-2099']

let returnedData = await $axios.get(queryUrl, { timeout: 60000 })
let returnedData = await $axios
.get(queryUrl, { timeout: 60000 })
.catch(err => {
console.error(err)
context.commit('setHttpError', 'server_error')
})

let partialData = false
expectedDataKeys.forEach(key => {
if (returnedData.data[key] == null) {
Expand Down
8 changes: 7 additions & 1 deletion store/climate.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,13 @@ export const actions = {
'2090_2099',
]

let returnedData = await $axios.get(queryUrl, { timeout: 60000 })
let returnedData = await $axios
.get(queryUrl, { timeout: 60000 })
.catch(err => {
console.error(err)
context.commit('setHttpError', 'server_error')
})

let partialData = false
expectedDataKeys.forEach(key => {
if (returnedData.data[key] == null) {
Expand Down
8 changes: 6 additions & 2 deletions store/elevation.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ export const actions = {
process.env.apiUrl +
'/elevation/' +
context.rootGetters['place/urlFragment']()
let returnedData = await $axios.get(queryUrl, { timeout: 60000 })

let returnedData = await $axios
.get(queryUrl, { timeout: 60000 })
.catch(err => {
console.error(err)
context.commit('setHttpError', 'server_error')
})
if (returnedData) {
context.commit('setElevation', returnedData.data)
} else {
Expand Down
8 changes: 7 additions & 1 deletion store/hydrology.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,13 @@ export const actions = {
process.env.apiUrl +
'/eds/hydrology/' +
context.rootGetters['place/urlFragment']()
let returnedData = await $axios.get(queryUrl, { timeout: 60000 })

let returnedData = await $axios
.get(queryUrl, { timeout: 60000 })
.catch(err => {
console.error(err)
context.commit('setHttpError', 'server_error')
})

if (returnedData) {
context.commit('setHydrologyData', returnedData.data.summary)
Expand Down
8 changes: 7 additions & 1 deletion store/indicators.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@ export const actions = {
process.env.apiUrl +
'/indicators/base/' +
context.rootGetters['place/urlFragment']()
let returnedData = await $axios.get(queryUrl, { timeout: 60000 })

let returnedData = await $axios
.get(queryUrl, { timeout: 60000 })
.catch(err => {
console.error(err)
context.commit('setHttpError', 'server_error')
})

if (returnedData) {
context.commit('setIndicatorData', returnedData.data)
Expand Down
8 changes: 7 additions & 1 deletion store/permafrost.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,13 @@ export const actions = {

let expectedDataKeys = ['2021-2039', '2040-2069', '2070-2099']

let returnedData = await $axios.get(queryUrl, { timeout: 60000 })
let returnedData = await $axios
.get(queryUrl, { timeout: 60000 })
.catch(err => {
console.error(err)
context.commit('setHttpError', 'server_error')
})

let partialData = false
expectedDataKeys.forEach(key => {
if (returnedData.data[key] == null) {
Expand Down
14 changes: 12 additions & 2 deletions store/wildfire.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,13 @@ export const actions = {
'2070-2099',
]

let returnedData = await $axios.get(queryUrl, { timeout: 60000 })
let returnedData = await $axios
.get(queryUrl, { timeout: 60000 })
.catch(err => {
console.error(err)
context.commit('setFlammabilityHttpError', 'server_error')
})

let partialData = false
expectedFlamKeys.forEach(key => {
if (returnedData.data[key] == null) {
Expand All @@ -234,7 +240,11 @@ export const actions = {

let expectedVegKeys = ['1950-2008', '2010-2039', '2040-2069', '2070-2099']

returnedData = await $axios.get(queryUrl, { timeout: 60000 })
returnedData = await $axios.get(queryUrl, { timeout: 60000 }).catch(err => {
console.error(err)
context.commit('setHttpError', 'server_error')
})

partialData = false
expectedVegKeys.forEach(key => {
if (returnedData.data[key] == null) {
Expand Down

0 comments on commit 55dcde9

Please sign in to comment.