From 6ef7279088e5883087b302115ae0c74f6eb644a4 Mon Sep 17 00:00:00 2001 From: Mattias Granlund Date: Sun, 14 Jul 2024 20:30:19 +0100 Subject: [PATCH] Use uknown error parameter in toasts.ts as well --- app/src/lib/notifications/toasts.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/app/src/lib/notifications/toasts.ts b/app/src/lib/notifications/toasts.ts index ffa6152d1..ea9baef02 100644 --- a/app/src/lib/notifications/toasts.ts +++ b/app/src/lib/notifications/toasts.ts @@ -21,12 +21,20 @@ export function showToast(toast: Toast) { ]); } -export function showError(title: string, error: any) { +export function showError(title: string, error: unknown) { // Silence GitHub octokit.js when disconnected - if (error.status === 500 && error.message === 'Load failed') return; - - const message = error.message || error.toString(); - showToast({ title, error: message, style: 'error' }); + // TODO: Fix this elsewhere. + if (error instanceof Object) { + if ( + 'status' in error && + 'message' in error && + error.status === 500 && + error.message === 'Load failed' + ) + return; + const message = 'message' in error ? error.message : String(error); + showToast({ title, error: message, style: 'error' }); + } } export function showInfo(title: string, message: string) {