diff --git a/src/controllers/employee-checkup-controller.ts b/src/controllers/employee-checkup-controller.ts index ede52f4..07bf28c 100644 --- a/src/controllers/employee-checkup-controller.ts +++ b/src/controllers/employee-checkup-controller.ts @@ -51,7 +51,7 @@ export class EmployeeCheckupController extends Controller { throw new HttpError( HttpStatus.NOT_FOUND, "Employee checkup cannot be found.", - "data_not_found", + "employeeCheckupNotFound", ); } return record; @@ -72,13 +72,13 @@ export class EmployeeCheckupController extends Controller { throw new HttpError( HttpStatus.BAD_REQUEST, "Province cannot be found.", - "missing_or_invalid_parameter", + "provinceNotFound", ); if (!employee) throw new HttpError( HttpStatus.BAD_REQUEST, "Employee cannot be found.", - "missing_or_invalid_parameter", + "employeeNotFound", ); } @@ -116,13 +116,13 @@ export class EmployeeCheckupController extends Controller { throw new HttpError( HttpStatus.BAD_REQUEST, "Province cannot be found.", - "missing_or_invalid_parameter", + "provinceNotFound", ); if (!employee) throw new HttpError( HttpStatus.BAD_REQUEST, "Employee cannot be found.", - "missing_or_invalid_parameter", + "employeeNotFound", ); } @@ -132,7 +132,7 @@ export class EmployeeCheckupController extends Controller { throw new HttpError( HttpStatus.NOT_FOUND, "Employee checkup cannot be found.", - "data_not_found", + "employeeCheckupNotFound", ); } @@ -160,7 +160,7 @@ export class EmployeeCheckupController extends Controller { throw new HttpError( HttpStatus.NOT_FOUND, "Employee checkup cannot be found.", - "data_not_found", + "employeeCheckupNotFound", ); } diff --git a/src/controllers/employee-controller.ts b/src/controllers/employee-controller.ts index 2dc9614..ab43b07 100644 --- a/src/controllers/employee-controller.ts +++ b/src/controllers/employee-controller.ts @@ -295,7 +295,7 @@ export class EmployeeController extends Controller { }); if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "Employee cannot be found.", "data_not_found"); + throw new HttpError(HttpStatus.NOT_FOUND, "Employee cannot be found.", "employeeNotFound"); } return record; @@ -316,25 +316,25 @@ export class EmployeeController extends Controller { throw new HttpError( HttpStatus.BAD_REQUEST, "Province cannot be found.", - "missing_or_invalid_parameter", + "relationProvinceNotFound", ); if (body.districtId !== district?.id) throw new HttpError( HttpStatus.BAD_REQUEST, "District cannot be found.", - "missing_or_invalid_parameter", + "relationDistrictNotFound", ); if (body.subDistrictId !== subDistrict?.id) throw new HttpError( HttpStatus.BAD_REQUEST, "Sub-district cannot be found.", - "missing_or_invalid_parameter", + "relationSubDistrictNotFound", ); if (!customerBranch) throw new HttpError( HttpStatus.BAD_REQUEST, "Customer Branch cannot be found.", - "missing_or_invalid_parameter", + "relationCustomerBranchNotFound", ); const { @@ -362,7 +362,7 @@ export class EmployeeController extends Controller { throw new HttpError( HttpStatus.BAD_REQUEST, "Some province cannot be found.", - "missing_or_invalid_parameter", + "someProvinceNotFound", ); } } @@ -476,28 +476,28 @@ export class EmployeeController 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.customerBranchId && !customerBranch) throw new HttpError( HttpStatus.BAD_REQUEST, "Customer cannot be found.", - "missing_or_invalid_parameter", + "relationCustomerNotFound", ); if (!employee) { - throw new HttpError(HttpStatus.NOT_FOUND, "Employee cannot be found.", "data_not_found"); + throw new HttpError(HttpStatus.NOT_FOUND, "Employee cannot be found.", "employeeNotFound"); } const { @@ -524,7 +524,7 @@ export class EmployeeController extends Controller { throw new HttpError( HttpStatus.BAD_REQUEST, "Some province cannot be found.", - "missing_or_invalid_parameter", + "someProvinceNotFound", ); } } @@ -652,14 +652,14 @@ export class EmployeeController extends Controller { const record = await prisma.employee.findFirst({ where: { id: employeeId } }); if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "Employee cannot be found.", "data_not_found"); + throw new HttpError(HttpStatus.NOT_FOUND, "Employee cannot be found.", "employeeNotFound"); } if (record.status !== Status.CREATED) { throw new HttpError( HttpStatus.FORBIDDEN, "Employee is in used.", - "missing_or_invalid_parameter", + "employeeInUsed", ); } diff --git a/src/controllers/employee-other-info-controller.ts b/src/controllers/employee-other-info-controller.ts index 3cb6284..4a2afd3 100644 --- a/src/controllers/employee-other-info-controller.ts +++ b/src/controllers/employee-other-info-controller.ts @@ -54,7 +54,7 @@ export class EmployeeOtherInfo extends Controller { throw new HttpError( HttpStatus.BAD_REQUEST, "Employee cannot be found.", - "missing_or_invalid_parameter", + "employeeBadReq", ); const record = await prisma.employeeOtherInfo.create({ @@ -82,7 +82,7 @@ export class EmployeeOtherInfo extends Controller { throw new HttpError( HttpStatus.NOT_FOUND, "Employee other info cannot be found.", - "data_not_found", + "employeeOtherNotFound", ); } @@ -106,7 +106,7 @@ export class EmployeeOtherInfo extends Controller { throw new HttpError( HttpStatus.NOT_FOUND, "Employee other info cannot be found.", - "data_not_found", + "employeeOtherNotFound", ); } diff --git a/src/controllers/employee-work-controller.ts b/src/controllers/employee-work-controller.ts index 90f1c8b..2336874 100644 --- a/src/controllers/employee-work-controller.ts +++ b/src/controllers/employee-work-controller.ts @@ -46,7 +46,7 @@ export class EmployeeWorkController extends Controller { where: { id: workId, employeeId }, }); if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "Employee work cannot be found.", "data_not_found"); + throw new HttpError(HttpStatus.NOT_FOUND, "Employee work cannot be found.", "employeeWorkNotFound"); } return record; } @@ -61,7 +61,7 @@ export class EmployeeWorkController extends Controller { throw new HttpError( HttpStatus.BAD_REQUEST, "Employee cannot be found.", - "missing_or_invalid_parameter", + "employeeBadReq", ); const record = await prisma.employeeWork.create({ @@ -86,7 +86,7 @@ export class EmployeeWorkController extends Controller { @Body() body: EmployeeWorkPayload, ) { if (!(await prisma.employeeWork.findUnique({ where: { id: workId, employeeId } }))) { - throw new HttpError(HttpStatus.NOT_FOUND, "Employee work cannot be found.", "data_not_found"); + throw new HttpError(HttpStatus.NOT_FOUND, "Employee work cannot be found.", "employeeWorkNotFound"); } const record = await prisma.employeeWork.update({ @@ -104,7 +104,7 @@ export class EmployeeWorkController extends Controller { const record = await prisma.employeeWork.findFirst({ where: { id: workId, employeeId } }); if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "Employee work cannot be found.", "data_not_found"); + throw new HttpError(HttpStatus.NOT_FOUND, "Employee work cannot be found.", "employeeWorkNotFound"); } return await prisma.employeeWork.delete({ where: { id: workId, employeeId } });