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