Skip to content

Commit c7fcd4b

Browse files
authored
Merge pull request #10 from metaversecloud-com/dev
add catch blocks
2 parents 9ad72dc + c463da8 commit c7fcd4b

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

server/controllers/session/handleGetDataObject.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { Request, Response } from "express";
44
export default async function handleGetDataObject(req: Request, res: Response) {
55
try {
66
const credentials = getCredentials(req.query);
7+
78
const keyAsset = await getDroppedAsset(credentials);
9+
if (!keyAsset.dataObject.landmarkZoneId) throw "No landmark zone ID found in data object";
810

911
if (keyAsset.error) {
1012
return res.status(404).json({ message: "Asset not found" });
@@ -17,9 +19,7 @@ export default async function handleGetDataObject(req: Request, res: Response) {
1719

1820
keyAsset.dataObject.participants = visitorProfileIds;
1921

20-
if (keyAsset) {
21-
return res.status(200).json(keyAsset.dataObject);
22-
}
22+
if (keyAsset) return res.status(200).json(keyAsset.dataObject);
2323
} catch (error: any) {
2424
return errorHandler({
2525
error,

server/controllers/session/handleSetBreakoutConfig.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,13 @@ export default async function handleSetBreakoutConfig(req: Request, res: Respons
235235
duration: 5,
236236
position: keyAsset.position,
237237
})
238-
.then()
239-
.catch(() => console.error("Error: Cannot trigger particle"));
238+
.catch((error) =>
239+
errorHandler({
240+
error,
241+
functionName: "handleSetBreakoutConfig",
242+
message: "Error triggering particle effects",
243+
}),
244+
);
240245

241246
placeVisitors(matches, visitorsObj, participants, keyAsset.id!, breakouts, privateZones);
242247
}, countdown * 1000);
@@ -341,17 +346,27 @@ export default async function handleSetBreakoutConfig(req: Request, res: Respons
341346

342347
const timeout = setTimeout(() => {
343348
const world = World.create(urlSlug, { credentials });
349+
world.triggerActivity({ type: WorldActivityType.GAME_ON, assetId }).catch((error) =>
350+
errorHandler({
351+
error,
352+
functionName: "handleSetBreakoutConfig",
353+
message: "Error triggering world activity",
354+
}),
355+
);
344356

345357
world
346358
.triggerParticle({
347359
name: "pastelConfetti_fall",
348360
duration: 5,
349361
position: keyAsset.position,
350362
})
351-
.then()
352-
.catch(() => console.error("Error: Cannot trigger particle"));
353-
354-
world.triggerActivity({ type: WorldActivityType.GAME_ON, assetId });
363+
.catch((error) =>
364+
errorHandler({
365+
error,
366+
functionName: "handleSetBreakoutConfig",
367+
message: "Error triggering world activity",
368+
}),
369+
);
355370

356371
placeVisitors(matches, visitorsObj, participants, keyAsset.id!, breakouts, privateZonesAtStart);
357372
}, countdown * 1000);

0 commit comments

Comments
 (0)