Refactor error handling in API services to use console.error instead of throwing errors

- Updated various API service files to replace error throwing with console.error for better logging.
- This change affects services related to aisles, assets, cameras, collaboration, comments, environment, lines, marketplace, simulation, visualization, and zones.
- The modifications aim to improve error handling by logging errors to the console instead of interrupting the flow with thrown errors.
This commit is contained in:
2025-06-24 09:31:45 +05:30
parent 385a64d307
commit b49f431ebf
97 changed files with 127 additions and 119 deletions

View File

@@ -14,7 +14,7 @@ export const createProject = async (projectUuid: string, userId: string, thumbna
body: JSON.stringify({ projectUuid, userId, thumbnail, organization, }),
});
if (!response.ok) {
throw new Error("Failed to add project");
console.error("Failed to add project");
}
const result = await response.json();

View File

@@ -23,7 +23,7 @@ export const deleteProject = async (
);
console.log("response: ", response);
if (!response.ok) {
throw new Error("Failed to clearPanel in the zone");
console.error("Failed to clearPanel in the zone");
}
const result = await response.json();

View File

@@ -18,13 +18,13 @@ export const deleteTrash = async (organization: string, projectId: string) => {
console.log("restore: ", response);
if (!response.ok) {
throw new Error("Failed to fetch trash data");
console.error("Failed to fetch trash data");
}
const data = await response.json();
return data;
} catch (error: any) {
console.error("Failed to fetch trash data:", error);
throw new Error(error.message || "Unknown error");
console.error(error.message || "Unknown error");
}
};

View File

@@ -22,7 +22,7 @@ export const duplicateProject = async (
console.log("response: ", response);
if (!response.ok) {
throw new Error("Failed to add project");
console.error("Failed to add project");
}
const result = await response.json();

View File

@@ -18,13 +18,13 @@ export const getTrash = async (organization: string) => {
);
if (!response.ok) {
throw new Error("Failed to fetch trash data");
console.error("Failed to fetch trash data");
}
const data = await response.json();
return data;
} catch (error: any) {
console.error("Failed to fetch trash data:", error);
throw new Error(error.message || "Unknown error");
console.error(error.message || "Unknown error");
}
};

View File

@@ -12,7 +12,7 @@ export const projectTutorial = async () => {
// console.log("response: ", response);
if (!response.ok) {
throw new Error("Failed to add project");
console.error("Failed to add project");
}
const result = await response.json();

View File

@@ -16,7 +16,7 @@ export const recentlyViewed = async (organization: string, userId: string) => {
);
if (!response.ok) {
throw new Error("Failed to fetch project");
console.error("Failed to fetch project");
}
return await response.json();

View File

@@ -17,7 +17,7 @@ export const restoreTrash = async (organization: string, projectId: string) => {
);
if (!response.ok) {
throw new Error("Failed to fetch trash data");
console.error("Failed to fetch trash data");
}
const data = await response.json();
@@ -25,6 +25,6 @@ export const restoreTrash = async (organization: string, projectId: string) => {
return data;
} catch (error: any) {
console.error("Failed to fetch trash data:", error);
throw new Error(error.message || "Unknown error");
console.error(error.message || "Unknown error");
}
};

View File

@@ -21,7 +21,7 @@ export const searchProject = async (
console.log("response: ", response);
if (!response.ok) {
throw new Error("Failed to Search project");
console.error("Failed to Search project");
}
const result = await response.json();

View File

@@ -20,7 +20,7 @@ export const trashSearchProject = async (
);
if (!response.ok) {
throw new Error("Failed to add project");
console.error("Failed to add project");
}
const result = await response.json();

View File

@@ -32,7 +32,7 @@ export const updateProject = async (
);
if (!response.ok) {
throw new Error("Failed to clearPanel in the zone");
console.error("Failed to clearPanel in the zone");
}
const result = await response.json();

View File

@@ -20,7 +20,7 @@ export const viewProject = async (
);
if (!response.ok) {
throw new Error("Failed to fetch");
console.error("Failed to fetch");
}
return await response.json();