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:
@@ -127,6 +127,7 @@ const DashboardCard: React.FC<DashBoardCardProps> = ({
|
||||
if (!projectId) return;
|
||||
try {
|
||||
const projects = await getAllProjects(userId, organization);
|
||||
if (!projects || !projects.Projects) return;
|
||||
// console.log("projects: ", projects);
|
||||
let projectUuid = projects.Projects.find(
|
||||
(val: any) => val.projectUuid === projectId || val._id === projectId
|
||||
|
||||
@@ -34,6 +34,7 @@ const DashboardProjects: React.FC = () => {
|
||||
const fetchAllProjects = async () => {
|
||||
try {
|
||||
const projects = await getAllProjects(userId, organization);
|
||||
if (!projects || !projects.Projects) return;
|
||||
|
||||
if (JSON.stringify(projects) !== JSON.stringify(workspaceProjects)) {
|
||||
setWorkspaceProjects(projects);
|
||||
|
||||
@@ -23,6 +23,7 @@ const LoadingPage: React.FC<LoadingPageProps> = ({ progress }) => {
|
||||
if (!userId) return;
|
||||
|
||||
getAllProjects(userId, organization).then((projects) => {
|
||||
if (!projects || !projects.Projects) return;
|
||||
const filterProject = projects?.Projects.find((val: any) => val.projectUuid === projectId || val._id === projectId);
|
||||
if (filterProject) {
|
||||
setProjectName(filterProject.projectName);
|
||||
|
||||
@@ -51,6 +51,7 @@ const FileMenu: React.FC = () => {
|
||||
if (!email || !userId) return;
|
||||
|
||||
const projects = await getAllProjects(userId, organization);
|
||||
if (!projects || !projects.Projects) return;
|
||||
// console.log('projects: ', projects);
|
||||
let projectUuid = projects.Projects.find((val: any) => val.projectUuid === projectId || val._id === projectId)
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ export const getUserData = (): UserData => {
|
||||
const [_, emailDomain] = email.split("@");
|
||||
|
||||
if (!emailDomain) {
|
||||
throw new Error("Invalid email format");
|
||||
console.error("Invalid email format");
|
||||
}
|
||||
|
||||
const [organization] = emailDomain.split(".");
|
||||
|
||||
@@ -16,7 +16,7 @@ async function loadInitialWallItems(
|
||||
const { organization, email } = getUserData();
|
||||
|
||||
if (!email) {
|
||||
throw new Error("No email found in localStorage");
|
||||
console.error("No email found in localStorage");
|
||||
}
|
||||
|
||||
const items = await getWallItems(organization, projectId, versionId);
|
||||
|
||||
@@ -276,7 +276,7 @@ export default function Builder() {
|
||||
<LayoutImage />
|
||||
</Bvh>
|
||||
|
||||
<WallGroup />
|
||||
{/* <WallGroup /> */}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ function loadOnlyFloors(
|
||||
const originalPoint = originalLines.flat().find(([point]) => point.x === x && point.z === z);
|
||||
|
||||
if (!originalPoint) {
|
||||
throw new Error(`Original point for coordinate [${x}, ${z}] not found.`);
|
||||
console.error(`Original point for coordinate [${x}, ${z}] not found.`);
|
||||
}
|
||||
|
||||
return originalPoint;
|
||||
|
||||
@@ -148,7 +148,7 @@ const FloorPlanGroup = ({ floorPlanGroup, floorPlanGroupLine, floorPlanGroupPoin
|
||||
}
|
||||
|
||||
if (toolMode === "Wall") {
|
||||
// drawWall(raycaster, plane, floorPlanGroupPoint, snappedPoint, isSnapped, isSnappedUUID, line, ispreSnapped, anglesnappedPoint, isAngleSnapped, lines, floorPlanGroupLine, floorPlanGroup, ReferenceLineMesh, LineCreated, currentLayerPoint, dragPointControls, setNewLines, setDeletedLines, activeLayer, socket, projectId, selectedVersion?.versionId || '',);
|
||||
drawWall(raycaster, plane, floorPlanGroupPoint, snappedPoint, isSnapped, isSnappedUUID, line, ispreSnapped, anglesnappedPoint, isAngleSnapped, lines, floorPlanGroupLine, floorPlanGroup, ReferenceLineMesh, LineCreated, currentLayerPoint, dragPointControls, setNewLines, setDeletedLines, activeLayer, socket, projectId, selectedVersion?.versionId || '',);
|
||||
}
|
||||
|
||||
if (toolMode === "Floor") {
|
||||
|
||||
@@ -13,12 +13,12 @@ import { Base } from '@react-three/csg';
|
||||
|
||||
function Wall({ wall }: { readonly wall: Wall }) {
|
||||
const { walls } = useWallStore();
|
||||
const { getWallType, isWallFlipped } = useWallClassification(walls);
|
||||
const wallType = getWallType(wall);
|
||||
const [visible, setVisible] = useState(true);
|
||||
const { wallVisibility } = useWallVisibility();
|
||||
const meshRef = useRef<any>();
|
||||
const { camera } = useThree();
|
||||
const { wallVisibility } = useWallVisibility();
|
||||
const { getWallType, isWallFlipped } = useWallClassification(walls);
|
||||
const [visible, setVisible] = useState(true);
|
||||
const meshRef = useRef<any>();
|
||||
const wallType = getWallType(wall);
|
||||
|
||||
const wallFlipped = isWallFlipped(wall);
|
||||
|
||||
@@ -84,7 +84,6 @@ function Wall({ wall }: { readonly wall: Wall }) {
|
||||
camera.getWorldDirection(u);
|
||||
if (!u || !v) return;
|
||||
setVisible((2 * v.dot(u)) <= 0.1);
|
||||
|
||||
} else {
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ function CommentInstances() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
getThreads();
|
||||
}, []);
|
||||
|
||||
@@ -34,6 +34,7 @@ export default function Scene({ layout }: { readonly layout: 'Main Layout' | 'Co
|
||||
if (!projectId && loadingProgress > 1) return;
|
||||
getAllProjects(userId, organization)
|
||||
.then((projects) => {
|
||||
if (!projects || !projects.Projects) return;
|
||||
let project = projects.Projects.find((val: any) => val.projectUuid === projectId || val._id === projectId);
|
||||
const canvas = document.getElementById("sceneCanvas")?.getElementsByTagName('canvas')[0];
|
||||
if (!canvas) return;
|
||||
|
||||
@@ -33,7 +33,7 @@ export const createHandleDrop = ({
|
||||
|
||||
const droppedData = JSON.parse(data);
|
||||
const canvasElement = document.getElementById("work-space-three-d-canvas");
|
||||
if (!canvasElement) throw new Error("Canvas element not found");
|
||||
if (!canvasElement) return;
|
||||
|
||||
const rect = canvasElement.getBoundingClientRect();
|
||||
const relativeX = event.clientX - rect.left;
|
||||
|
||||
@@ -680,7 +680,7 @@ export default function Dropped3dWidgets() {
|
||||
event.preventDefault();
|
||||
|
||||
const canvasElement = document.getElementById("work-space-three-d-canvas");
|
||||
if (!canvasElement) throw new Error("Canvas element not found");
|
||||
if (!canvasElement) return;
|
||||
|
||||
const canvasRect = canvasElement.getBoundingClientRect();
|
||||
const relativeX = event.clientX - canvasRect.left;
|
||||
@@ -744,7 +744,7 @@ export default function Dropped3dWidgets() {
|
||||
const canvasElement = document.getElementById(
|
||||
"work-space-three-d-canvas"
|
||||
);
|
||||
if (!canvasElement) throw new Error("Canvas element not found");
|
||||
if (!canvasElement) return;
|
||||
const canvasRect = canvasElement.getBoundingClientRect();
|
||||
const relativeX = event.clientX - canvasRect.left;
|
||||
const relativeY = event.clientY - canvasRect.top;
|
||||
|
||||
@@ -56,11 +56,14 @@ const Project: React.FC = () => {
|
||||
}
|
||||
|
||||
getAllProjects(userId, organization).then((projects) => {
|
||||
if (!projects || !projects.Projects) return;
|
||||
const filterProject = projects?.Projects.find((val: any) => val.projectUuid === projectId || val._id === projectId)
|
||||
setProjectName(filterProject.projectName)
|
||||
viewProject(organization, filterProject._id, userId).then((viewedProject) => {
|
||||
});
|
||||
});
|
||||
}).catch(() => {
|
||||
console.error("Error fetching projects")
|
||||
})
|
||||
|
||||
}, []);
|
||||
|
||||
@@ -79,6 +82,8 @@ const Project: React.FC = () => {
|
||||
})
|
||||
})
|
||||
setVersions(versions);
|
||||
}).catch(() => {
|
||||
console.error("Error fetching version history")
|
||||
})
|
||||
}, [projectId])
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ const UserAuth: React.FC = () => {
|
||||
const organization = email.split("@")[1].split(".")[0];
|
||||
try {
|
||||
const res = await signInApi(email, password, organization, fingerprint);
|
||||
// console.log('res: ', res);
|
||||
if (res.message.message === "login successfull") {
|
||||
setError("");
|
||||
setOrganization(organization);
|
||||
@@ -57,6 +56,7 @@ const UserAuth: React.FC = () => {
|
||||
|
||||
try {
|
||||
const projects = await recentlyViewed(organization, res.message.userId);
|
||||
console.log('projects: ', projects);
|
||||
if (res.message.isShare) {
|
||||
if (Object.values(projects.RecentlyViewed).length > 0) {
|
||||
const firstId = (Object.values(projects?.RecentlyViewed || {})[0] as any)?._id;
|
||||
@@ -72,7 +72,6 @@ const UserAuth: React.FC = () => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error fetching recent projects:", error);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -11,7 +11,7 @@ export const getAssetDetails = async (filename: string) => {
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch asset details");
|
||||
console.error("Failed to fetch asset details");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -3,7 +3,7 @@ export const fetchAssets = async () => {
|
||||
try {
|
||||
const response = await fetch(`${BackEnd_url}/api/v1/getAllAssets`);
|
||||
if (!response.ok) {
|
||||
throw new Error("Network response was not ok");
|
||||
console.error("Network response was not ok");
|
||||
}
|
||||
const result = await response.json();
|
||||
// const last10Assets = result.slice(-10);
|
||||
|
||||
@@ -13,7 +13,7 @@ export const fetchGltfUrl = async (filename: string, AssetID: string) => {
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch asset details");
|
||||
console.error("Failed to fetch asset details");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -12,7 +12,7 @@ export const getSortedAssets = async (category: any, orders: any) => {
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Error: ${response.statusText}`);
|
||||
console.error(`Error: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -17,7 +17,7 @@ export const upsertProductOrEventApi = async (body: any) => {
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to add product or event");
|
||||
console.error("Failed to add product or event");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -17,7 +17,7 @@ export const deleteEventDataApi = async (body: any) => {
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to delete event data");
|
||||
console.error("Failed to delete event data");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -17,7 +17,7 @@ export const deleteProductApi = async (body: any) => {
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to delete product data");
|
||||
console.error("Failed to delete product data");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -19,7 +19,7 @@ export const getProductApi = async (
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch product data");
|
||||
console.error("Failed to fetch product data");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -16,7 +16,7 @@ export const getAllProductsApi = async (projectId: string, versionId: string) =>
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch all products data");
|
||||
console.error("Failed to fetch all products data");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -19,7 +19,7 @@ export const renameProductApi = async (body: {
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to rename product");
|
||||
console.error("Failed to rename product");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -18,7 +18,7 @@ export const adding3dWidgets = async (
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to add 3dwidget in the zone");
|
||||
console.error("Failed to add 3dwidget in the zone");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -24,7 +24,7 @@ export const addingFloatingWidgets = async (
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to add Floatingwidget in the zone");
|
||||
console.error("Failed to add Floatingwidget in the zone");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -21,7 +21,7 @@ export const addingWidgets = async (
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to add widget in the zone");
|
||||
console.error("Failed to add widget in the zone");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -18,7 +18,7 @@ export const clearPanel = 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();
|
||||
|
||||
@@ -22,7 +22,7 @@ export const delete3dWidgetApi = async (
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to delete floating widget in the zone");
|
||||
console.error("Failed to delete floating widget in the zone");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -21,7 +21,7 @@ export const deleteFloatingWidgetApi = async (
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to delete floating widget in the zone");
|
||||
console.error("Failed to delete floating widget in the zone");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -19,7 +19,7 @@ export const deletePanelApi = async (
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to delete widget in the zone");
|
||||
console.error("Failed to delete widget in the zone");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -20,7 +20,7 @@ export const deleteTemplateApi = async (
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to delete template ");
|
||||
console.error("Failed to delete template ");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -19,7 +19,7 @@ export const deleteWidgetApi = async (
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to delete widget in the zone");
|
||||
console.error("Failed to delete widget in the zone");
|
||||
}
|
||||
const result = await response.json();
|
||||
return result;
|
||||
|
||||
@@ -18,7 +18,7 @@ export const duplicateWidgetApi = async (
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to duplicate widget in the zone");
|
||||
console.error("Failed to duplicate widget in the zone");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -22,7 +22,7 @@ export const get3dWidgetZoneData = async (
|
||||
}
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch Zone3dWidgetData");
|
||||
console.error("Failed to fetch Zone3dWidgetData");
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
|
||||
@@ -21,7 +21,7 @@ export const getFloatingZoneData = async (
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch ZoneFloatingData");
|
||||
console.error("Failed to fetch ZoneFloatingData");
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
|
||||
@@ -17,7 +17,7 @@ export const getSelect2dZoneData = async (zoneUuid?: string, organization?: stri
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch zoneDatas");
|
||||
console.error("Failed to fetch zoneDatas");
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
|
||||
@@ -16,7 +16,7 @@ export const getTemplateData = async (organization?: string, projectId?: string,
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch ZoneFloatingData");
|
||||
console.error("Failed to fetch ZoneFloatingData");
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
|
||||
@@ -15,7 +15,7 @@ export const getZone2dData = async (organization?: string, projectId?: string, v
|
||||
}
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch zoneDatas");
|
||||
console.error("Failed to fetch zoneDatas");
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
|
||||
@@ -17,7 +17,7 @@ export const getZoneData = async (zoneUuid: string, organization: string, projec
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch zoneData");
|
||||
console.error("Failed to fetch zoneData");
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
|
||||
@@ -21,7 +21,7 @@ export const loadTempleteApi = async (
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to load Template in the zone");
|
||||
console.error("Failed to load Template in the zone");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -18,7 +18,7 @@ export const lockPanel = async (
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to Lock Panel in the zone");
|
||||
console.error("Failed to Lock Panel in the zone");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -19,7 +19,7 @@ export const panelData = async (
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to add panelOrder for Zone");
|
||||
console.error("Failed to add panelOrder for Zone");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -14,7 +14,7 @@ export const saveTemplateApi = async (organization: string, template: {}) => {
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to save template zone");
|
||||
console.error("Failed to save template zone");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -29,7 +29,7 @@ export const update3dWidget = async (
|
||||
|
||||
if (!response.ok) {
|
||||
echo.error("Failed to update 3d widget");
|
||||
throw new Error("Failed to add 3dwidget in the zone");
|
||||
console.error("Failed to add 3dwidget in the zone");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
@@ -70,7 +70,7 @@ export const update3dWidgetRotation = async (
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to add 3dwidget in the zone");
|
||||
console.error("Failed to add 3dwidget in the zone");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
@@ -15,7 +15,7 @@ export const zoneCameraUpdate = async (zoneData: {}, organization: string, proje
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to update camera position in the zone");
|
||||
console.error("Failed to update camera position in the zone");
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
Reference in New Issue
Block a user