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:
@@ -20,7 +20,7 @@ export const createAisleApi = async (
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to add project");
|
||||
console.error("Failed to add project");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -13,7 +13,7 @@ export const deleteAisleApi = async (aisleUuid: string, projectId: string, versi
|
||||
body: JSON.stringify({ aisleUuid, projectId }),
|
||||
});
|
||||
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();
|
||||
|
||||
@@ -17,7 +17,7 @@ export const getAisleApi = async (projectId: string, versionId: string) => {
|
||||
|
||||
// console.log("response: ", response);
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch");
|
||||
console.error("Failed to fetch");
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
|
||||
@@ -13,7 +13,7 @@ export const getAssetImages = async (cursor?: string) => {
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch assets");
|
||||
console.error("Failed to fetch assets");
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
|
||||
@@ -13,7 +13,7 @@ export const getAssetModel = async (modelId: string) => {
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch model");
|
||||
console.error("Failed to fetch model");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -18,7 +18,7 @@ export const deleteFloorItem = async (
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to delete Floor Item");
|
||||
console.error("Failed to delete Floor Item");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -17,7 +17,7 @@ export const getFloorAssets = async (organization: string, projectId?: string, v
|
||||
|
||||
// console.log('response: ', response);
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to get assets");
|
||||
console.error("Failed to get assets");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -13,7 +13,7 @@ export const setAssetsApi = async (data: any) => {
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to set or update Floor Item");
|
||||
console.error("Failed to set or update Floor Item");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -18,7 +18,7 @@ export const deleteWallItem = async (
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to delete Wall Item");
|
||||
console.error("Failed to delete Wall Item");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -17,7 +17,7 @@ export const getWallItems = async (organization: string, projectId?: string, ver
|
||||
|
||||
// console.log('response: ', response);
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to get Wall Items");
|
||||
console.error("Failed to get Wall Items");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -31,7 +31,7 @@ export const setWallItem = async (
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to set or update Wall Item");
|
||||
console.error("Failed to set or update Wall Item");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -16,7 +16,7 @@ export const getCamera = async (organization: string, userId: string, projectId?
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to get Camera position and target");
|
||||
console.error("Failed to get Camera position and target");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -23,7 +23,7 @@ export const setCamera = async (
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to set Camera Position and Target");
|
||||
console.error("Failed to set Camera Position and Target");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -12,11 +12,11 @@ export default async function getActiveUsersData(organization: string) {
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Error: ${response.status} - ${response.statusText}`);
|
||||
console.error(`Error: ${response.status} - ${response.statusText}`);
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to get active cameras ");
|
||||
console.error("Failed to get active cameras ");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -12,11 +12,11 @@ export default async function fetchShareUsers(organization: string) {
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Error: ${response.status} - ${response.statusText}`);
|
||||
console.error(`Error: ${response.status} - ${response.statusText}`);
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to get users ");
|
||||
console.error("Failed to get users ");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -15,7 +15,7 @@ export default async function giveCollabAccess(
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to set Camera Position and Target");
|
||||
console.error("Failed to set Camera Position and Target");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -29,7 +29,7 @@ export const addCommentsApi = 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();
|
||||
@@ -38,9 +38,9 @@ export const addCommentsApi = async (
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.error(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.error("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,16 +19,16 @@ export const createThreadApi = async (
|
||||
body: JSON.stringify({ projectId, state, position, rotation, threadTitle }),
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to add project");
|
||||
console.error("Failed to add project");
|
||||
}
|
||||
const result = await response.json();
|
||||
console.log('result: ', result);
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.error(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.error("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,16 +28,16 @@ export const deleteCommentApi = 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();
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.error(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.error("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -20,16 +20,16 @@ export const deleteThreadApi = async (projectId: string, threadId: string) => {
|
||||
});
|
||||
|
||||
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();
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.error(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.error("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,16 +28,16 @@ export const editThreadTitleApi = 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();
|
||||
return result;
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.error(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.error("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -14,21 +14,22 @@ export const getAllThreads = async (projectId: string) => {
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to get assets");
|
||||
console.error("Failed to get assets");
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
// console.log('result: ', result);
|
||||
console.log('result: ', result);
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
echo.error("Failed to get floor asset");
|
||||
if (error instanceof Error) {
|
||||
throw new Error(error.message);
|
||||
console.error(error.message);
|
||||
} else {
|
||||
throw new Error("An unknown error occurred");
|
||||
console.error("An unknown error occurred");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ export const findEnvironment = async (organization: string, userId: string, proj
|
||||
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to get wall and roof visibility");
|
||||
console.error("Failed to get wall and roof visibility");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -37,7 +37,7 @@ export const setEnvironment = async (
|
||||
|
||||
// console.log('responseenv: ', response);
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to set wall and roof visibility");
|
||||
console.error("Failed to set wall and roof visibility");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -11,7 +11,7 @@ export const deleteLayer = async (organization: string, layer: number) => {
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to delete line");
|
||||
console.error("Failed to delete line");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -11,7 +11,7 @@ export const deleteLineApi = async (organization: string, line: Object) => {
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to delete line");
|
||||
console.error("Failed to delete line");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -11,7 +11,7 @@ export const deletePointApi = async (organization: string, uuid: string) => {
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to delete point");
|
||||
console.error("Failed to delete point");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -16,7 +16,7 @@ export const getLines = async (organization: string, projectId?: string, version
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to get Lines");
|
||||
console.error("Failed to get Lines");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -16,7 +16,7 @@ export const setLine = async (
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to set line");
|
||||
console.error("Failed to set line");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -15,7 +15,7 @@ export const updatePoint = async (
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to update point");
|
||||
console.error("Failed to update point");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -14,7 +14,7 @@ export const signUpApi = async (
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to signUpApi");
|
||||
console.error("Failed to signUpApi");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -23,7 +23,7 @@ export const createVersionApi = async (projectId: string, createdBy: string, hie
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to create Version History");
|
||||
console.error("Failed to create Version History");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -16,7 +16,7 @@ export const getVersionDataApi = async (projectId: string, versionId: string) =>
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to get Version Data");
|
||||
console.error("Failed to get Version Data");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -16,7 +16,7 @@ export const getVersionHistoryApi = async (projectId: string, page?: number, lim
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to get Version History");
|
||||
console.error("Failed to get Version History");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -15,7 +15,7 @@ export const deleteZonesApi = async (
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to delete zone");
|
||||
console.error("Failed to delete zone");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -17,7 +17,7 @@ export const getZonesApi = async (organization: string, projectId?: string, vers
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to get Zones");
|
||||
console.error("Failed to get Zones");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -15,7 +15,7 @@ export const setZonesApi = async (
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to set zone");
|
||||
console.error("Failed to set zone");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
Reference in New Issue
Block a user