Skip to content

Commit

Permalink
Error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
captainbrosset committed Nov 19, 2024
1 parent 1f93d63 commit 69c5921
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions idb-getallrecords/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,35 +175,34 @@ <h3></h3>
newReadButton.addEventListener("click", async () => {
setAsLoading();
startMeasuring();

let error = null;

try {
await readInBatches(db, batchSize);
} catch (e) {
if (useGetAllRecords) {
durationLabel.textContent = "Your browser doesn't support getAllRecords() yet.";
}
error = e;
} finally {
const duration = stopMeasuring();
setAsReady();
durationLabel.textContent = error ? "Your browser doesn't support getAllRecords()" : `Read in ${duration}ms`;
}

const duration = stopMeasuring();
setAsReady();
durationLabel.textContent = `Read in ${duration}ms`;

});

newReadReverseButton.addEventListener("click", async () => {
setAsLoading();
startMeasuring();

let error = null;

try {
await readInBatchesReverse(db, batchSize);
} catch (e) {
if (useGetAllRecords) {
durationLabel.textContent = "Your browser doesn't support getAllRecords() yet.";
}
error = e;
} finally {
const duration = stopMeasuring();
setAsReady();
durationLabel.textContent = error ? "Your browser doesn't support getAllRecords()" : `Read in ${duration}ms`;
}

const duration = stopMeasuring();
setAsReady();
durationLabel.textContent = `Read in ${duration}ms`;
});

setAsReady();
Expand Down

0 comments on commit 69c5921

Please sign in to comment.