From b7e1a318a8d14cca746dbb19c49134415f8d200f Mon Sep 17 00:00:00 2001 From: evlist Date: Sun, 25 Sep 2022 18:47:37 +0200 Subject: [PATCH] Adding error log messages. --- src/db/tracks.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/db/tracks.ts b/src/db/tracks.ts index 4734b6d..7c586e3 100644 --- a/src/db/tracks.ts +++ b/src/db/tracks.ts @@ -64,17 +64,23 @@ const initialTrack = { export const appendTrkpt = async (db: any, trkpt: any) => { var track: any; - await db.get(CURRENT_TRACK) + await db + .get(CURRENT_TRACK) .then((result: any) => { track = result; }) - .catch(() => { + .catch((error: any) => { + console.log(`db.get(CURRENT_TRACK), ERROR: ${JSON.stringify(error)}`); track = initialTrack; }); track.metadata.lastModified = trkpt.time; const currentTrkseg = track.track.trk.at(-1).trkseg.at(-1); currentTrkseg.trkpt.push(trkpt); - db.put(track).then((response: any) => { - console.log(`db.put(track), response: ${JSON.stringify(response)}`); - }); + db.put(track) + .then((response: any) => { + console.log(`db.put(track), response: ${JSON.stringify(response)}`); + }) + .catch((error: any) => { + console.log(`db.put(CURRENT_TRACK), ERROR: ${JSON.stringify(error)}`); + }); };