From 9b0ef8ba643ea81cfe1b28aa61b470dfc26106a4 Mon Sep 17 00:00:00 2001 From: Saish Mungase Date: Sat, 17 Jan 2026 01:15:22 +0530 Subject: [PATCH] refactor: replace generic console logs with contextual error handling --- js/utils/utils.js | 8 +++----- planet/js/ProjectStorage.js | 10 ++++------ planet/js/Publisher.js | 5 ++--- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/js/utils/utils.js b/js/utils/utils.js index 2c6a35be2b..b80d94d214 100644 --- a/js/utils/utils.js +++ b/js/utils/utils.js @@ -696,11 +696,9 @@ const processPluginData = (activity, pluginData, pluginSource) => { let obj; try { obj = JSON.parse(pluginData); - } catch (e) { - // eslint-disable-next-line no-console - console.log(pluginData); - // eslint-disable-next-line no-console - console.log(e); + } catch (error) { + console.error(`PluginProcessor: Failed to parse plugin data from source "${pluginSource}":`, error); + console.debug("Malformed plugin data:", pluginData); return null; } // Create a palette entry. diff --git a/planet/js/ProjectStorage.js b/planet/js/ProjectStorage.js index 5e67ce7ac3..61a0f77ccc 100644 --- a/planet/js/ProjectStorage.js +++ b/planet/js/ProjectStorage.js @@ -188,9 +188,8 @@ class ProjectStorage { try { return JSON.parse(jsonobj); - } catch (e) { - // eslint-disable-next-line no-console - console.log(e); + } catch (error) { + console.error(`ProjectStorage: Failed to parse JSON data for key "${key}":`, error); return null; } } @@ -205,9 +204,8 @@ class ProjectStorage { try { this.data = typeof currentData === "string" ? JSON.parse(currentData) : currentData; - } catch (e) { - // eslint-disable-next-line no-console - console.log(e); + } catch (error) { + console.error("ProjectStorage: Critical failure during storage state restoration.", error); return null; } } diff --git a/planet/js/Publisher.js b/planet/js/Publisher.js index 0bbdb8dc3e..16e6a420f8 100644 --- a/planet/js/Publisher.js +++ b/planet/js/Publisher.js @@ -304,9 +304,8 @@ class Publisher { parseProject(tb) { try { tb = JSON.parse(tb); - } catch (e) { - // eslint-disable-next-line no-console - console.log(e); + } catch (error) { + console.error("Publisher: Failed to parse project data for keyword extraction.", error); return ""; }