Skip to content

Commit 239eb62

Browse files
committed
improved errors
1 parent 560a670 commit 239eb62

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

client/src/shapes/animation/index.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ export const useAnimatedShapes = () => {
7070
return;
7171
}
7272

73+
const shapeName = schemaIdToShapeName.get(schemaId);
74+
if (!shapeName) {
75+
throw new Error('(Internal Error) Animation set without shape name mapping. this should never happen!');
76+
}
77+
7378
for (const animation of animations) {
7479
const timeline = timelineIdToTimeline.get(animation.timelineId);
7580
if (!timeline) throw new Error('animation activated without a timeline!');
@@ -79,17 +84,9 @@ export const useAnimatedShapes = () => {
7984
...animation,
8085
};
8186

82-
const shapeName = schemaIdToShapeName.get(schemaId);
83-
if (!shapeName) {
84-
console.warn(
85-
'animation set without shape name mapping. this should never happen!',
86-
);
87-
continue;
88-
}
89-
90-
if (!animationWithTimeline.validShapes.has(shapeName)) {
91-
console.warn('invalid shape name!');
92-
continue;
87+
const { validShapes, timelineId } = animationWithTimeline
88+
if (!validShapes.has(shapeName)) {
89+
throw new Error(`(Internal Error) Attempted to apply inappropriate animation to schema! Animation timeline ${timelineId} only works for shapes ${Array.from(validShapes.keys())} but schema ${schemaId} is of shape ${shapeName}.`);
9390
}
9491

9592
// cleanup animation if expired

0 commit comments

Comments
 (0)