Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: expose exhort backend errors to clients #128

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 34 additions & 27 deletions src/analysis.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {EOL} from "os";
import {RegexNotToBeLogged, getCustom} from "./tools.js";

Check warning on line 2 in src/analysis.js

View workflow job for this annotation

GitHub Actions / Lint and test project (18)

Expected 'multiple' syntax before 'single' syntax

Check warning on line 2 in src/analysis.js

View workflow job for this annotation

GitHub Actions / Lint and test project (latest)

Expected 'multiple' syntax before 'single' syntax

export default { requestComponent, requestStack, validateToken }

Expand Down Expand Up @@ -34,26 +34,29 @@
body: provided.content
})
let result
if(!html) {
result = await resp.json()
}
else {
result = await resp.text()
}
if (process.env["EXHORT_DEBUG"] === "true") {
let exRequestId = resp.headers.get("ex-request-id");
if(exRequestId)
{
console.log("Unique Identifier associated with this request - ex-request-id=" + exRequestId)
if(resp.status === 200) {
if (!html) {
result = await resp.json()
} else {
result = await resp.text()
}
EndTime = new Date()
console.log("Response body received from exhort server : " + EOL + EOL)
console.log(console.log(JSON.stringify(result,null , 4)))
console.log("Ending time of sending stack analysis request to exhort server= " + EndTime)
let time = (EndTime - startTime) / 1000
console.log("Total Time in seconds: " + time)
if (process.env["EXHORT_DEBUG"] === "true") {
let exRequestId = resp.headers.get("ex-request-id");
if (exRequestId) {
console.log("Unique Identifier associated with this request - ex-request-id=" + exRequestId)
}
EndTime = new Date()
console.log("Response body received from exhort server : " + EOL + EOL)
console.log(console.log(JSON.stringify(result, null, 4)))
console.log("Ending time of sending stack analysis request to exhort server= " + EndTime)
let time = (EndTime - startTime) / 1000
console.log("Total Time in seconds: " + time)

}
} else {
throw new Error(`Got error response from exhort backend - http return code : ${resp.status}, error message => ${await resp.text()}`)
}

return Promise.resolve(result)
}

Expand All @@ -80,18 +83,22 @@
},
body: provided.content
})
let result = await resp.json()
if (process.env["EXHORT_DEBUG"] === "true") {
let exRequestId = resp.headers.get("ex-request-id");
if(exRequestId)
{
console.log("Unique Identifier associated with this request - ex-request-id=" + exRequestId)
}
console.log("Response body received from exhort server : " + EOL + EOL)
console.log(JSON.stringify(result,null , 4))
console.log("Ending time of sending component analysis request to exhort server= " + new Date())
let result
if(resp.status === 200) {
result = await resp.json()
if (process.env["EXHORT_DEBUG"] === "true") {
let exRequestId = resp.headers.get("ex-request-id");
if (exRequestId) {
console.log("Unique Identifier associated with this request - ex-request-id=" + exRequestId)
}
console.log("Response body received from exhort server : " + EOL + EOL)
console.log(JSON.stringify(result, null, 4))
console.log("Ending time of sending component analysis request to exhort server= " + new Date())


}
} else {
throw new Error(`Got error response from exhort backend - http return code : ${resp.status}, error message => ${await resp.text()}`)
}

return Promise.resolve(result)
Expand Down
Loading