Skip to content

Commit

Permalink
Fix bug with error handling and await for context.sync()
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhinav Rau committed Aug 22, 2024
1 parent 71720ff commit d3ac557
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/search_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ function checkDocumentLinks(rowNum, result, link_1_Column, link_2_Column, link_3
const cell = actualSummaryColumn.getRange().getCell(rowNum, 0);
cell.clear(Excel.ClearApplyTo.formats);
cell.values = [[result.summary.summaryText]];
context.sync();
await context.sync();
// match summaries only if they are not null or empty
if (expectedSummary[rowNum][0] !== null && expectedSummary[rowNum][0] !== "") {
const score_cell = summaryScoreColumn.getRange().getCell(rowNum, 0);
Expand Down Expand Up @@ -317,7 +317,7 @@ function checkDocumentLinks(rowNum, result, link_1_Column, link_2_Column, link_3

}
finally {
context.sync();
await context.sync();
}

}
Expand Down
6 changes: 3 additions & 3 deletions src/summarization_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function getSummarizationConfig() {
const worksheetName = currentWorksheet.name;
const configTable = currentWorksheet.tables.getItem(`${worksheetName}.ConfigTable`);
const valueColumn = getColumn(configTable, "Value");
await context.sync();


config = {
vertexAIProjectID: valueColumn.values[1][0],
Expand Down Expand Up @@ -227,7 +227,7 @@ async function processResponse(rowNum,
const cell_summary = summaryColumn.getRange().getCell(rowNum, 0);
cell_summary.clear(Excel.ClearApplyTo.formats);
cell_summary.values = [[output]];
context.sync();
await context.sync();


try {
Expand Down Expand Up @@ -262,7 +262,7 @@ async function processResponse(rowNum,
cell_status.format.fill.color = '#FFCCCB';
cell_status.values = [["Failed. Error: " + err.message]];
} finally {
context.sync();
await context.sync();
}


Expand Down
4 changes: 2 additions & 2 deletions src/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ export function appendError(message, error) {
const newLogEntry = {
time: new Date().toLocaleTimeString(), // Get only time
level: error !== null ? "ERROR" : "INFO",
message: error !== null ? message + '\n' + error.message : message
message: error !== null ? "message:" + message + "ErrMesg:" + error.message : message
};

$("#log-pane").tabulator("addRow", newLogEntry, "top"); // Add the new log entry to the top of the table

if (error !== null) {
console.error(message + '\n' + error.message);
console.error("message:" + message + "ErrMesg:" + error.message);
} else {
console.log(message);
}
Expand Down

0 comments on commit d3ac557

Please sign in to comment.