Show graphql error message (#1852)

Co-authored-by: StephaneBischoffSSENSE <stephane.bischoff@ssense.com>
Co-authored-by: Liyas Thomas <liyascthomas@gmail.com>
This commit is contained in:
Stephane
2021-10-03 22:31:47 -04:00
committed by GitHub
parent 2ab1d3dbfa
commit 06161bc963
4 changed files with 38 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
import axios from "axios"
import { decodeB64StringToArrayBuffer } from "../utils/b64"
import { settingsStore } from "~/newstore/settings"
import { JsonFormattedError } from "~/helpers/utils/JsonFormattedError"
let cancelSource = axios.CancelToken.source()
@@ -39,7 +40,6 @@ const axiosWithProxy = async (req) => {
// eslint-disable-next-line no-throw-literal
throw "cancellation"
} else {
console.error(e)
throw e
}
}
@@ -52,14 +52,16 @@ const axiosWithoutProxy = async (req, _store) => {
cancelToken: (cancelSource && cancelSource.token) || "",
responseType: "arraybuffer",
})
return res
} catch (e) {
if (axios.isCancel(e)) {
// eslint-disable-next-line no-throw-literal
throw "cancellation"
} else if (e.response?.data) {
throw new JsonFormattedError(
JSON.parse(Buffer.from(e.response.data, "base64").toString("utf8"))
)
} else {
console.error(e)
throw e
}
}