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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user