Display parsing errors in InfluxQLEditor if present
parent
f063245db8
commit
ca0d885bf5
|
@ -148,16 +148,25 @@ const handleSuccess = (
|
|||
}
|
||||
|
||||
const handleError = (
|
||||
error,
|
||||
error: string,
|
||||
query: Query,
|
||||
editQueryStatus: EditQueryStatusFunction
|
||||
): void => {
|
||||
const message =
|
||||
getDeep<string>(error, 'data.message', '') ||
|
||||
getDeep<string>(error, 'message', 'Could not retrieve data')
|
||||
|
||||
// 400 from chrono server = fail
|
||||
editQueryStatus(query.id, {
|
||||
error: message,
|
||||
error: extractErrorMessage(error),
|
||||
})
|
||||
}
|
||||
|
||||
const extractErrorMessage = (errorMessage: string): string => {
|
||||
if (!errorMessage) {
|
||||
return 'Could not retrieve data'
|
||||
}
|
||||
|
||||
const parseErrorMatch = errorMessage.match('error parsing query')
|
||||
|
||||
if (parseErrorMatch) {
|
||||
return errorMessage.slice(parseErrorMatch.index)
|
||||
}
|
||||
|
||||
return errorMessage
|
||||
}
|
||||
|
|
|
@ -7,8 +7,19 @@ const proxy = async msg => {
|
|||
method: 'POST',
|
||||
body: JSON.stringify({query, rp, db, uuid}),
|
||||
})
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
if (!response.ok) {
|
||||
let message = 'proxy request failed'
|
||||
|
||||
if (data && data.message) {
|
||||
message = data.message
|
||||
}
|
||||
|
||||
return Promise.reject(message)
|
||||
}
|
||||
|
||||
return {data}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue