Skip to content

Commit

Permalink
TSP-412 Minor improvements (#67)
Browse files Browse the repository at this point in the history
Made minor improvement in error handling during send script and fixed
issue with for loop related to saving instruments

Co-authored-by: GT, Shreya <[email protected]>
  • Loading branch information
Shreya-GT and GT, Shreya authored Oct 28, 2024
1 parent 7c273b0 commit 7c1a91a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
11 changes: 7 additions & 4 deletions src/communicationmanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ export class CommunicationManager {
"Sending script to terminal",
)
},
(reason) => {
void vscode.window.showErrorMessage(reason as string)
(error: unknown) => {
const err_msg = (error as Error).message
void vscode.window.showErrorMessage(
"Unable to send script to terminal. Error: " + err_msg,
)
},
)
}
Expand Down Expand Up @@ -134,8 +137,8 @@ export class CommunicationManager {
() => {
isConnSuccessful = true
},
(reason) => {
err_msg = reason as string
(error: unknown) => {
err_msg = (error as Error).message
isConnSuccessful = false
},
)
Expand Down
18 changes: 8 additions & 10 deletions src/instruments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -824,10 +824,11 @@ export class NewTDPModel {

//check for redundant entries
public addToConnectionList(instr: InstrInfo) {
let res: InstrInfo | undefined = undefined
let idx = -1
let status = "add_new"
if (this.connection_list.length == 0) {
this.connection_list.push(instr)
return
} else {
for (let i = 0; i < this.connection_list.length; i++) {
if (
Expand All @@ -839,23 +840,20 @@ export class NewTDPModel {
instr.instr_address
) {
idx = i
res = instr
status = "update"
break
} else {
status = "no_change"
break
}
} else {
res = instr
}
}
}

if (res != undefined) {
if (idx > -1) {
this.connection_list[idx] = res
} else {
this.connection_list.push(res)
}
if (status == "add_new") {
this.connection_list.push(instr)
} else if (status == "update") {
this.connection_list[idx] = instr
}
}

Expand Down

0 comments on commit 7c1a91a

Please sign in to comment.