Skip to content

Commit 69c5921

Browse files
Error handling
1 parent 1f93d63 commit 69c5921

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

idb-getallrecords/index.html

+16-17
Original file line numberDiff line numberDiff line change
@@ -175,35 +175,34 @@ <h3></h3>
175175
newReadButton.addEventListener("click", async () => {
176176
setAsLoading();
177177
startMeasuring();
178-
178+
let error = null;
179+
179180
try {
180181
await readInBatches(db, batchSize);
181182
} catch (e) {
182-
if (useGetAllRecords) {
183-
durationLabel.textContent = "Your browser doesn't support getAllRecords() yet.";
184-
}
183+
error = e;
184+
} finally {
185+
const duration = stopMeasuring();
186+
setAsReady();
187+
durationLabel.textContent = error ? "Your browser doesn't support getAllRecords()" : `Read in ${duration}ms`;
185188
}
186-
187-
const duration = stopMeasuring();
188-
setAsReady();
189-
durationLabel.textContent = `Read in ${duration}ms`;
189+
190190
});
191-
191+
192192
newReadReverseButton.addEventListener("click", async () => {
193193
setAsLoading();
194194
startMeasuring();
195-
195+
let error = null;
196+
196197
try {
197198
await readInBatchesReverse(db, batchSize);
198199
} catch (e) {
199-
if (useGetAllRecords) {
200-
durationLabel.textContent = "Your browser doesn't support getAllRecords() yet.";
201-
}
200+
error = e;
201+
} finally {
202+
const duration = stopMeasuring();
203+
setAsReady();
204+
durationLabel.textContent = error ? "Your browser doesn't support getAllRecords()" : `Read in ${duration}ms`;
202205
}
203-
204-
const duration = stopMeasuring();
205-
setAsReady();
206-
durationLabel.textContent = `Read in ${duration}ms`;
207206
});
208207

209208
setAsReady();

0 commit comments

Comments
 (0)