diff --git a/src/controllers/branch-contact-controller.ts b/src/controllers/branch-contact-controller.ts index 473fd51..e2e3d6c 100644 --- a/src/controllers/branch-contact-controller.ts +++ b/src/controllers/branch-contact-controller.ts @@ -62,7 +62,7 @@ export class BranchContactController extends Controller { throw new HttpError( HttpStatus.NOT_FOUND, "Branch contact cannot be found.", - "data_not_found", + "branchContactNotFound", ); } @@ -78,8 +78,8 @@ export class BranchContactController extends Controller { if (!(await prisma.branch.findFirst({ where: { id: branchId } }))) { throw new HttpError( HttpStatus.BAD_REQUEST, - "Branch not found.", - "missing_or_invalid_parameter", + "Branch cannot be found.", + "branchBadReq", ); } const record = await prisma.branchContact.create({ @@ -106,7 +106,7 @@ export class BranchContactController extends Controller { throw new HttpError( HttpStatus.NOT_FOUND, "Branch contact cannot be found.", - "data_not_found", + "branchContactNotFound", ); } @@ -125,7 +125,7 @@ export class BranchContactController extends Controller { throw new HttpError( HttpStatus.NOT_FOUND, "Branch contact cannot be found.", - "data_not_found", + "branchContactNotFound", ); } } diff --git a/src/controllers/branch-controller.ts b/src/controllers/branch-controller.ts index 889c5a1..bf61974 100644 --- a/src/controllers/branch-controller.ts +++ b/src/controllers/branch-controller.ts @@ -208,7 +208,7 @@ export class BranchController extends Controller { }); if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "Branch cannot be found.", "data_not_found"); + throw new HttpError(HttpStatus.NOT_FOUND, "Branch cannot be found.", "branchNotFound"); } return Object.assign(record, { @@ -229,25 +229,25 @@ export class BranchController extends Controller { throw new HttpError( HttpStatus.BAD_REQUEST, "Province cannot be found.", - "missing_or_invalid_parameter", + "relationProvinceNotFound", ); if (body.districtId && !district) throw new HttpError( HttpStatus.BAD_REQUEST, "District cannot be found.", - "missing_or_invalid_parameter", + "relationDistrictNotFound", ); if (body.subDistrictId && !subDistrict) throw new HttpError( HttpStatus.BAD_REQUEST, "Sub-district cannot be found.", - "missing_or_invalid_parameter", + "relationSubDistrictNotFound", ); if (body.headOfficeId && !head) throw new HttpError( HttpStatus.BAD_REQUEST, - "Head branch cannot be found.", - "missing_or_invalid_parameter", + "Headquaters cannot be found.", + "relationHQNotFound", ); const { provinceId, districtId, subDistrictId, headOfficeId, contact, ...rest } = body; @@ -337,8 +337,8 @@ export class BranchController extends Controller { if (body.headOfficeId === branchId) throw new HttpError( HttpStatus.BAD_REQUEST, - "Cannot make this as head office and branch at the same time.", - "missing_or_invalid_parameter", + "Cannot make this as headquaters and branch at the same time.", + "cantMakeHQAndBranchSameTime", ); if (body.subDistrictId || body.districtId || body.provinceId || body.headOfficeId) { @@ -352,32 +352,32 @@ export class BranchController extends Controller { throw new HttpError( HttpStatus.BAD_REQUEST, "Province cannot be found.", - "missing_or_invalid_parameter", + "relationProvinceNotFound", ); if (body.districtId && !district) throw new HttpError( HttpStatus.BAD_REQUEST, "District cannot be found.", - "missing_or_invalid_parameter", + "relationDistrictNotFound", ); if (body.subDistrictId && !subDistrict) throw new HttpError( HttpStatus.BAD_REQUEST, "Sub-district cannot be found.", - "missing_or_invalid_parameter", + "relationSubDistrictNotFound", ); if (body.headOfficeId && !branch) throw new HttpError( HttpStatus.BAD_REQUEST, - "Head branch cannot be found.", - "missing_or_invalid_parameter", + "Headquaters cannot be found.", + "relationHQNotFound", ); } const { provinceId, districtId, subDistrictId, headOfficeId, contact, ...rest } = body; if (!(await prisma.branch.findUnique({ where: { id: branchId } }))) { - throw new HttpError(HttpStatus.NOT_FOUND, "Branch cannot be found.", "data_not_found"); + throw new HttpError(HttpStatus.NOT_FOUND, "Branch cannot be found.", "branchNotFound"); } const record = await prisma.branch.update({ @@ -445,11 +445,11 @@ export class BranchController extends Controller { }); if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "Branch cannot be found.", "data_not_found"); + throw new HttpError(HttpStatus.NOT_FOUND, "Branch cannot be found.", "branchNotFound"); } if (record.status !== Status.CREATED) { - throw new HttpError(HttpStatus.FORBIDDEN, "Branch is in used.", "data_in_used"); + throw new HttpError(HttpStatus.FORBIDDEN, "Branch is in used.", "branchInUsed"); } await minio.removeObject(MINIO_BUCKET, lineImageLoc(branchId), { diff --git a/src/controllers/branch-user-controller.ts b/src/controllers/branch-user-controller.ts index a12c546..539dd2e 100644 --- a/src/controllers/branch-user-controller.ts +++ b/src/controllers/branch-user-controller.ts @@ -116,7 +116,7 @@ export class BranchUserController extends Controller { throw new HttpError( HttpStatus.BAD_REQUEST, "Branch cannot be found.", - "missing_or_invalid_parameter", + "branchBadReq", ); } @@ -124,7 +124,7 @@ export class BranchUserController extends Controller { throw new HttpError( HttpStatus.BAD_REQUEST, "One or more user cannot be found.", - "missing_or_invalid_parameter", + "oneOrMoreUserBadReq", ); } @@ -234,7 +234,7 @@ export class UserBranchController extends Controller { throw new HttpError( HttpStatus.BAD_REQUEST, "One or more branch cannot be found.", - "missing_or_invalid_parameter", + "oneOrMoreBranchBadReq", ); }