From 6bd1a8f5e3227c102e852e9a808103e4d51ef676 Mon Sep 17 00:00:00 2001 From: Dylan Cerenov Date: Sun, 24 Sep 2023 16:28:13 -0400 Subject: [PATCH] Added more accurate error logging --- packages/api-v2/src/plan/plan.errors.ts | 21 +++++++++++++++++++++ packages/api-v2/src/plan/plan.service.ts | 6 +++++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 packages/api-v2/src/plan/plan.errors.ts diff --git a/packages/api-v2/src/plan/plan.errors.ts b/packages/api-v2/src/plan/plan.errors.ts new file mode 100644 index 000000000..626c4c3f9 --- /dev/null +++ b/packages/api-v2/src/plan/plan.errors.ts @@ -0,0 +1,21 @@ +// InvalidMajor +// InvalidCatalogYear +// InvalidConcentration + +export class InvalidMajor extends Error { + constructor() { + super(); + } +} + +export class InvalidCatalogYear extends Error { + constructor() { + super(); + } +} + +export class InvalidConcentration extends Error { + constructor() { + super(); + } +} diff --git a/packages/api-v2/src/plan/plan.service.ts b/packages/api-v2/src/plan/plan.service.ts index 12322e8ba..e6b3c88ac 100644 --- a/packages/api-v2/src/plan/plan.service.ts +++ b/packages/api-v2/src/plan/plan.service.ts @@ -7,6 +7,7 @@ import { CreatePlanDto, UpdatePlanDto } from "@graduate/common"; import { Plan } from "./entities/plan.entity"; import { formatServiceCtx } from "../../src/utils"; import { MajorService } from "../major/major.service"; +import { InvalidConcentration, InvalidMajor } from "./plan.errors"; @Injectable() export class PlanService { @@ -179,7 +180,7 @@ export class PlanService { }, this.formatPlanServiceCtx("update") ); - + throw new InvalidMajor(); return null; } @@ -201,8 +202,11 @@ export class PlanService { this.formatPlanServiceCtx("update") ); + throw new InvalidConcentration(); return null; } + + } /**