Testing error status on db.get().

This commit is contained in:
Eric van der Vlist 2022-09-25 18:54:13 +02:00
parent b7e1a318a8
commit aea83fac5d
1 changed files with 8 additions and 3 deletions

View File

@ -70,9 +70,13 @@ export const appendTrkpt = async (db: any, trkpt: any) => {
track = result;
})
.catch((error: any) => {
console.log(`db.get(CURRENT_TRACK), ERROR: ${JSON.stringify(error)}`);
track = initialTrack;
});
if (error.status='404') {
track = initialTrack;
} else {
console.log(`db.get(CURRENT_TRACK), ERROR: ${JSON.stringify(error)}`);
alert(`db.get(CURRENT_TRACK), ERROR: ${JSON.stringify(error)}`);
}
});
track.metadata.lastModified = trkpt.time;
const currentTrkseg = track.track.trk.at(-1).trkseg.at(-1);
currentTrkseg.trkpt.push(trkpt);
@ -82,5 +86,6 @@ export const appendTrkpt = async (db: any, trkpt: any) => {
})
.catch((error: any) => {
console.log(`db.put(CURRENT_TRACK), ERROR: ${JSON.stringify(error)}`);
alert(`db.put(CURRENT_TRACK), ERROR: ${JSON.stringify(error)}`);
});
};