refactor: better toast messages + minor ui improvements
This commit is contained in:
@@ -16,8 +16,8 @@ import { GQLHeader } from "~/newstore/GQLSession"
|
||||
const GQL_SCHEMA_POLL_INTERVAL = 7000
|
||||
|
||||
/**
|
||||
GQLConnection deals with all the operations (like polling, schema extraction) that runs
|
||||
when a connection is made to a GraphQL server.
|
||||
GQLConnection deals with all the operations (like polling, schema extraction) that runs
|
||||
when a connection is made to a GraphQL server.
|
||||
*/
|
||||
export class GQLConnection {
|
||||
public isLoading$ = new BehaviorSubject<boolean>(false)
|
||||
@@ -172,7 +172,8 @@ export class GQLConnection {
|
||||
this.schema$.next(schema)
|
||||
|
||||
this.isLoading$.next(false)
|
||||
} catch (error: any) {
|
||||
} catch (e: any) {
|
||||
console.error(e)
|
||||
this.disconnect()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +58,8 @@ export const JavascriptFetchCodegen = {
|
||||
requestString.push(" response.headers\n")
|
||||
requestString.push(" response.url\n\n")
|
||||
requestString.push(" return response.text()\n")
|
||||
requestString.push("}).catch(function(error) {\n")
|
||||
requestString.push(" error.message\n")
|
||||
requestString.push("}).catch(function(e) {\n")
|
||||
requestString.push(" console.error(e)\n")
|
||||
requestString.push("})")
|
||||
return requestString.join("")
|
||||
},
|
||||
|
||||
@@ -56,8 +56,8 @@ export const JavascriptJqueryCodegen = {
|
||||
requestString.push(".then(response => {\n")
|
||||
requestString.push(" console.log(response);\n")
|
||||
requestString.push("})")
|
||||
requestString.push(".catch(error => {\n")
|
||||
requestString.push(" console.log(error);\n")
|
||||
requestString.push(".catch(e => {\n")
|
||||
requestString.push(" console.error(e);\n")
|
||||
requestString.push("})\n")
|
||||
return requestString.join("")
|
||||
},
|
||||
|
||||
@@ -51,8 +51,8 @@ export const NodejsAxiosCodegen = {
|
||||
requestString.push(".then(response => {\n")
|
||||
requestString.push(" console.log(response);\n")
|
||||
requestString.push("})")
|
||||
requestString.push(".catch(error => {\n")
|
||||
requestString.push(" console.log(error);\n")
|
||||
requestString.push(".catch(e => {\n")
|
||||
requestString.push(" console.error(e);\n")
|
||||
requestString.push("})\n")
|
||||
return requestString.join("")
|
||||
},
|
||||
|
||||
@@ -216,7 +216,6 @@ export async function setProviderInfo(id: string, token: string) {
|
||||
.catch((e) => console.error("error updating", us, e))
|
||||
} catch (e) {
|
||||
console.error("error updating", e)
|
||||
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ async function writeEnvironments(environment: Environment[]) {
|
||||
.set(ev)
|
||||
} catch (e) {
|
||||
console.error("error updating", ev, e)
|
||||
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,27 +97,27 @@ export function createRESTNetworkRequestStream(
|
||||
|
||||
response.complete()
|
||||
})
|
||||
.catch((err) => {
|
||||
if (err.response) {
|
||||
.catch((e) => {
|
||||
if (e.response) {
|
||||
const timeEnd = Date.now()
|
||||
|
||||
const contentLength = err.response.headers["content-length"]
|
||||
? parseInt(err.response.headers["content-length"])
|
||||
: (err.response.data as ArrayBuffer).byteLength
|
||||
const contentLength = e.response.headers["content-length"]
|
||||
? parseInt(e.response.headers["content-length"])
|
||||
: (e.response.data as ArrayBuffer).byteLength
|
||||
|
||||
const resObj: HoppRESTResponse = {
|
||||
type: "fail",
|
||||
body: err.response.data,
|
||||
headers: Object.keys(err.response.headers).map((x) => ({
|
||||
body: e.response.data,
|
||||
headers: Object.keys(e.response.headers).map((x) => ({
|
||||
key: x,
|
||||
value: err.response.headers[x],
|
||||
value: e.response.headers[x],
|
||||
})),
|
||||
meta: {
|
||||
responseDuration: timeEnd - timeStart,
|
||||
responseSize: contentLength,
|
||||
},
|
||||
req,
|
||||
statusCode: err.response.status,
|
||||
statusCode: e.response.status,
|
||||
}
|
||||
|
||||
response.next(resObj)
|
||||
@@ -126,7 +126,7 @@ export function createRESTNetworkRequestStream(
|
||||
} else {
|
||||
const resObj: HoppRESTResponse = {
|
||||
type: "network_fail",
|
||||
error: err,
|
||||
error: e,
|
||||
req,
|
||||
}
|
||||
|
||||
|
||||
@@ -31,9 +31,8 @@ const sendPostRequest = async (url, params) => {
|
||||
const response = await fetch(url, options)
|
||||
const data = await response.json()
|
||||
return data
|
||||
} catch (err) {
|
||||
console.error("Request failed", err)
|
||||
throw err
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,9 +72,8 @@ const getTokenConfiguration = async (endpoint) => {
|
||||
const response = await fetch(endpoint, options)
|
||||
const config = await response.json()
|
||||
return config
|
||||
} catch (err) {
|
||||
console.error("Request failed", err)
|
||||
throw err
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,8 +223,8 @@ const oauthRedirect = () => {
|
||||
redirect_uri: redirectUri,
|
||||
code_verifier: getLocalConfig("pkce_codeVerifier"),
|
||||
})
|
||||
} catch (err) {
|
||||
console.log(`${error.error}\n\n${error.error_description}`)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
// Clean these up since we don't need them anymore
|
||||
|
||||
@@ -39,6 +39,7 @@ const axiosWithProxy = async (req) => {
|
||||
// eslint-disable-next-line no-throw-literal
|
||||
throw "cancellation"
|
||||
} else {
|
||||
console.error(e)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
@@ -58,6 +59,7 @@ const axiosWithoutProxy = async (req, _store) => {
|
||||
// eslint-disable-next-line no-throw-literal
|
||||
throw "cancellation"
|
||||
} else {
|
||||
console.error(e)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,8 +631,8 @@ export function validateFile(server, query, file) {
|
||||
var visitors = makeVisitors(server, query, file, messages)
|
||||
walk.simple(ast, visitors, infer.searchVisitor, state)
|
||||
return { messages: messages }
|
||||
} catch (err) {
|
||||
console.error(err.stack)
|
||||
} catch (e) {
|
||||
console.error(e.stack)
|
||||
return { messages: [] }
|
||||
}
|
||||
}
|
||||
@@ -680,8 +680,8 @@ export function validateFiles(server, query) {
|
||||
messages.push({ file: file.name, messages: messagesFile })
|
||||
}
|
||||
return { messages: messages }
|
||||
} catch (err) {
|
||||
console.error(err.stack)
|
||||
} catch (e) {
|
||||
console.error(e.stack)
|
||||
return { messages: [] }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ export function parseUrlAndPath(value) {
|
||||
const url = new URL(value)
|
||||
result.url = url.origin
|
||||
result.path = url.pathname
|
||||
} catch (error) {
|
||||
} catch (e) {
|
||||
const uriRegex = value.match(
|
||||
/^((http[s]?:\/\/)?(<<[^/]+>>)?[^/]*|)(\/?.*)$/
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user