about summary refs log tree commit diff
path: root/src/state/models/notifications-view.ts
diff options
context:
space:
mode:
authorPaul Frazee <pfrazee@gmail.com>2023-01-02 21:39:15 -0600
committerPaul Frazee <pfrazee@gmail.com>2023-01-02 21:39:15 -0600
commit4eabc2d65aa742e6cf55822943f04275531d0375 (patch)
tree645742da4a45eef45019d2d0193f022b3672e01c /src/state/models/notifications-view.ts
parent6885fb2b41efdb29e386cf696ea7304baf3a87c8 (diff)
downloadvoidsky-4eabc2d65aa742e6cf55822943f04275531d0375.tar.zst
Improve error logging
Diffstat (limited to 'src/state/models/notifications-view.ts')
-rw-r--r--src/state/models/notifications-view.ts21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/state/models/notifications-view.ts b/src/state/models/notifications-view.ts
index 38a8ca133..44f92dd2f 100644
--- a/src/state/models/notifications-view.ts
+++ b/src/state/models/notifications-view.ts
@@ -151,7 +151,7 @@ export class NotificationsViewItemModel implements GroupedNotification {
       await this.additionalPost.setup().catch(e => {
         this.rootStore.log.error(
           'Failed to load post needed by notification',
-          e.toString(),
+          e,
         )
       })
     }
@@ -266,10 +266,7 @@ export class NotificationsViewModel {
       })
       this.rootStore.me.clearNotificationCount()
     } catch (e: any) {
-      this.rootStore.log.warn(
-        'Failed to update notifications read state',
-        e.toString(),
-      )
+      this.rootStore.log.warn('Failed to update notifications read state', e)
     }
   }
 
@@ -282,11 +279,15 @@ export class NotificationsViewModel {
     this.error = ''
   }
 
-  private _xIdle(err: string = '') {
+  private _xIdle(err?: any) {
     this.isLoading = false
     this.isRefreshing = false
     this.hasLoaded = true
     this.error = cleanError(err)
+    this.error = err ? cleanError(err) : ''
+    if (err) {
+      this.rootStore.log.error('Failed to fetch notifications', err)
+    }
   }
 
   // loader functions
@@ -314,7 +315,7 @@ export class NotificationsViewModel {
       await this._replaceAll(res)
       this._xIdle()
     } catch (e: any) {
-      this._xIdle(`Failed to load notifications: ${e.toString()}`)
+      this._xIdle(e)
     }
   }
 
@@ -332,7 +333,7 @@ export class NotificationsViewModel {
       await this._appendAll(res)
       this._xIdle()
     } catch (e: any) {
-      this._xIdle(`Failed to load notifications: ${e.toString()}`)
+      this._xIdle(e)
     }
   }
 
@@ -359,7 +360,7 @@ export class NotificationsViewModel {
       } while (numToFetch > 0)
       this._xIdle()
     } catch (e: any) {
-      this._xIdle(`Failed to update notifications: ${e.toString()}`)
+      this._xIdle(e)
     }
   }
 
@@ -386,7 +387,7 @@ export class NotificationsViewModel {
     await Promise.all(promises).catch(e => {
       this.rootStore.log.error(
         'Uncaught failure during notifications-view _appendAll()',
-        e.toString(),
+        e,
       )
     })
     runInAction(() => {