Skip to content

Commit 7c7eed4

Browse files
committed
Fix exception handling.
1 parent 93fdbc2 commit 7c7eed4

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

src/apiService.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import axios from 'axios'
22

33
namespace ApiService {
44
const interval = 1000; // set polling interval to 1 second
5-
const timeout = 12000;
5+
const timeout = 120000;
66

77
export async function getToken(username: string, password: string) {
88
console.log('Authenticating in ARQAN')
@@ -32,15 +32,16 @@ namespace ApiService {
3232
}
3333
}
3434
)
35-
3635
const task_id = response.data.task_id
36+
console.log("Task id: ", task_id)
3737

3838
response = await axios.get(`http://51.250.88.251:8000/api/tasks/sec-req-extract/${task_id}`, {
3939
headers: {
4040
'Authorization': `Bearer ${token}`,
4141
'accept': 'application/json'
4242
}
4343
});
44+
4445
const startTime = new Date().getTime();
4546
while (response.status === 202 && new Date().getTime() - startTime < timeout) {
4647
await new Promise(resolve => setTimeout(resolve, interval)); // Wait for interval before making another request
@@ -52,6 +53,8 @@ namespace ApiService {
5253
});
5354
}
5455

56+
console.log("Outside cycle")
57+
console.log(response.status)
5558
if (response.status === 202) {
5659
throw new Error('Polling timed out');
5760
}

src/requirement.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,10 @@ import {Stig} from './interfaces'
44

55
namespace Requirement {
66
export async function isSecurity(issue: string, token: string): Promise<boolean> {
7-
console.log('In isSecurity function')
87
// API call to ARQAN to classify the requirement
98
let securitySentences = await ApiService.getSecuritySentences(issue, token).then(
109
(result) => {
1110
return result.requirements
12-
},
13-
(error) => {
14-
throw new Error(
15-
`Received ${error.response.status} status code from ARQAN Classification Service for input: ${issue}.`
16-
)
1711
}
1812
)
1913

0 commit comments

Comments
 (0)