From 933975bb8fce69cc642e13cf3f74388c1d504bf1 Mon Sep 17 00:00:00 2001
From: Ole Langbehn <ole.langbehn@inoio.de>
Date: Tue, 13 Aug 2024 15:54:34 +0200
Subject: [PATCH] NOISSUE don't trigger alerts on recoverable errors

These error logs alerted in production, they are a false positive
---
 app/betterplace.ts | 6 +++---
 app/logging.ts     | 4 ++++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/app/betterplace.ts b/app/betterplace.ts
index a3ce666..edb72c7 100644
--- a/app/betterplace.ts
+++ b/app/betterplace.ts
@@ -151,7 +151,7 @@ export const fetchCategories = async (projectId: number): Promise<string[]> => {
     const categories = json.data as Array<ApiProjectCategory>;
     return categories.map(transformProjectCategory);
   } catch (e) {
-    logger.error(
+    logger.warn(
       `Error while fetching project categories from '${href}', using empty array to handle this (somewhat) gracefully`,
       e,
     );
@@ -173,7 +173,7 @@ export const fetchNews = async (
     const news = json.data as ApiBlogPost[];
     return news.map(transformNews);
   } catch (e) {
-    logger.error(
+    logger.warn(
       `Error while fetching blog posts from '${href}', using empty array to handle this (somewhat) gracefully`,
       e,
     );
@@ -192,7 +192,7 @@ export const fetchInitiativeUrl = async (
     const organisation: ApiOrganisation = await response.json();
     return organisation.links.find((l) => l.rel === "platform")?.href;
   } catch (e) {
-    logger.error(
+    logger.warn(
       `Error while fetching organisation url from '${initiative.url}', using api url to handle this (somewhat) gracefully`,
       e,
     );
diff --git a/app/logging.ts b/app/logging.ts
index dcd2660..06779e5 100644
--- a/app/logging.ts
+++ b/app/logging.ts
@@ -88,6 +88,10 @@ class Logger {
     this.log(LogSeverity.INFO, message, options);
   }
 
+  warn(message: string, options = {}) {
+    this.log(LogSeverity.WARNING, message, options);
+  }
+
   error(message: string, options = {}) {
     this.log(LogSeverity.ERROR, message, options);
   }
-- 
GitLab