fix(ui): propagate network failure

pull/5611/head
Pavel Zavora 2020-11-11 09:40:14 +01:00
parent 5c1aac9ebb
commit de2a15906a
2 changed files with 8 additions and 3 deletions

View File

@ -51,7 +51,8 @@ export const extractQueryErrorMessage = (errorMessage: string): string => {
return 'Could not retrieve data'
}
const parseErrorMatch = errorMessage.match('error parsing query')
const parseErrorMatch =
errorMessage.match && errorMessage.match('error parsing query')
if (parseErrorMatch) {
return errorMessage.slice(parseErrorMatch.index)

View File

@ -93,7 +93,7 @@ async function AJAX<T = any>(
headers = {},
}: RequestParams,
excludeBasepath = false
): Promise<(T | T & {links: object}) | AxiosResponse<T>> {
): Promise<(T | (T & {links: object})) | AxiosResponse<T>> {
try {
url = addBasepath(url, excludeBasepath)
@ -117,7 +117,11 @@ async function AJAX<T = any>(
return links ? generateResponseWithLinks(response, links) : response
} catch (error) {
const {response} = error
throw links ? generateResponseWithLinks(response, links) : response // eslint-disable-line no-throw-literal
if (response) {
throw links ? generateResponseWithLinks(response, links) : response // eslint-disable-line no-throw-literal
} else {
throw error
}
}
}