Bubble AJAX errors up to fetchTimeSeries

pull/10616/head
Andrew Watkins 2017-03-29 13:38:29 -07:00
parent a1d7933c57
commit cd1271fde4
3 changed files with 22 additions and 12 deletions

View File

@ -52,20 +52,22 @@ const ChronoTable = React.createClass({
}
},
fetchCellData(query) {
this.setState({isLoading: true})
async fetchCellData(query) {
this.setState({isLoading: true});
// second param is db, we want to leave this blank
fetchTimeSeries(query.host, undefined, query.text).then((resp) => {
const cellData = _.get(resp.data, ['results', '0', 'series', '0'], false)
try {
const {data} = await fetchTimeSeries(query.host, undefined, query.text)
const cellData = _.get(data, ['results', '0', 'series', '0'], false);
if (!cellData) {
return this.setState({isLoading: false})
}
this.setState({
cellData,
isLoading: false,
})
})
this.setState({cellData, isLoading: false})
} catch (error) {
console.error(error.message)
this.setState({error: error.message, isLoading: false})
}
},
componentDidMount() {

View File

@ -1,5 +1,12 @@
import {proxy} from 'utils/queryUrlGenerator'
export default function fetchTimeSeries(source, database, query) {
return proxy({source, query, database})
const fetchTimeSeries = async (source, database, query) => {
try {
return await proxy({source, query, database})
} catch (error) {
console.error('error from proxy: ', error)
throw error
}
}
export default fetchTimeSeries

View File

@ -12,6 +12,7 @@ export const proxy = async ({source, query, db, rp}) => {
},
})
} catch (error) {
console.error(error) // eslint-disable-line no-console
console.error(error)
throw error
}
}