From aea83fac5d2eba930d738a7a4a9c663fa35b9cc2 Mon Sep 17 00:00:00 2001 From: evlist Date: Sun, 25 Sep 2022 18:54:13 +0200 Subject: [PATCH] Testing error status on db.get(). --- src/db/tracks.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/db/tracks.ts b/src/db/tracks.ts index 7c586e3..884fd0a 100644 --- a/src/db/tracks.ts +++ b/src/db/tracks.ts @@ -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)}`); }); };