Skip to content

Commit 376833c

Browse files
committed
Expose all StepProgressInput errors
1 parent da7cd3f commit 376833c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/components/product-progress/product-progress.service.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,21 @@ export class ProductProgressService {
152152
);
153153
}
154154

155-
input.steps.forEach((step, index) => {
155+
const errors = input.steps.flatMap((step, index) => {
156156
if (!scope.steps.includes(step.step)) {
157-
throw new StepNotPlannedException(input.productId, step.step, index);
157+
return new StepNotPlannedException(input.productId, step.step, index);
158158
}
159159
if (step.completed && step.completed > scope.progressTarget) {
160-
throw new InputException(
160+
return new InputException(
161161
"Completed value cannot exceed product's progress target",
162162
`steps.${index}.completed`,
163163
);
164164
}
165+
return [];
165166
});
167+
if (errors.length > 0) {
168+
throw new AggregateError(errors);
169+
}
166170

167171
const progress = await this.repo.update(input);
168172
return this.secure(progress, this.privilegesFor(session, scope))!;

0 commit comments

Comments
 (0)