Skip to content

Commit

Permalink
WD-8308 - feat: Add comments to errors that should continue to only b…
Browse files Browse the repository at this point in the history
…e logged to the console (#1688)
  • Loading branch information
vladimir-cucu authored Jan 29, 2024
1 parent 0d0ae5f commit da7ba74
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/hooks/useLocalStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function useLocalStorage<V>(
const item = window.localStorage.getItem(key);
return item ? JSON.parse(item) : initialValue;
} catch (error) {
// Not shown in UI. Logged for debugging purposes.
console.error("Unable to parse local storage:", error);
return initialValue;
}
Expand All @@ -24,6 +25,7 @@ function useLocalStorage<V>(
setStoredValue(value);
window.localStorage.setItem(key, stringified);
} catch (error) {
// Not shown in UI. Logged for debugging purposes.
console.error(error);
}
};
Expand Down
2 changes: 2 additions & 0 deletions src/juju/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ function startPingerLoop(conn: ConnectionWithFacades) {
const intervalId = window.setInterval(() => {
conn.facades.pinger?.ping(null).catch((e) => {
// If the pinger fails for whatever reason then cancel the ping.
// Not shown in UI. Logged for debugging purposes.
console.error("pinger stopped,", e);
stopPingerLoop(intervalId);
});
Expand Down Expand Up @@ -379,6 +380,7 @@ export async function fetchAllModelStatuses(
dispatch(
addControllerCloudRegion({ wsControllerURL, modelInfo }),
).catch((error) =>
// Not shown in UI. Logged for debugging purposes.
console.error(
"Error when trying to add controller cloud and region data.",
error,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ const generateApplicationRow = (
const parts = actionData.action.receiver.match(/unit-(.+)-\d+/);
const appName = parts && parts[1];
if (!appName) {
// Not shown in UI. Logged for debugging purposes.
console.error(
"Unable to parse action receiver",
actionData.action.receiver,
Expand Down
6 changes: 5 additions & 1 deletion src/pages/ModelDetails/ModelDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ export default function ModelDetails() {
conn,
watcherHandle["watcher-id"],
pingerIntervalId,
).catch((error) => console.error(Label.MODEL_WATCHER_ERROR, error));
).catch((error) =>
// Error doesn’t interfere with the user’s interaction with the
// dashboard. Not shown in UI. Logged for debugging purposes.
console.error(Label.MODEL_WATCHER_ERROR, error),
);
}
};
// Skipped as we need appState due to the call to `connectAndLoginToModel`
Expand Down
2 changes: 2 additions & 0 deletions src/store/middleware/check-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type { RootState, Store } from "store/store";
import { isPayloadAction } from "types";

function error(name: string, wsControllerURL?: string | null) {
// Not shown in UI. Logged for debugging purposes.
console.error(
"Unable to perform action: ",
name,
Expand All @@ -28,6 +29,7 @@ function error(name: string, wsControllerURL?: string | null) {

export const checkLoggedIn = (state: RootState, wsControllerURL: string) => {
if (!wsControllerURL) {
// Not shown in UI. Logged for debugging purposes.
console.error(
"Unable to determine logged in status. " +
"'wsControllerURL' was not provided in the action that was dispatched.",
Expand Down

0 comments on commit da7ba74

Please sign in to comment.