• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ULL-ESIT-INF-DSI-2526 / grp02-medcore-api-groupd / 25635510066

10 May 2026 05:46PM UTC coverage: 86.473% (-2.3%) from 88.754%
25635510066

push

github

DiegoPrietoG
feat: enhance error handling in staff modification controllers and update validation messages in staff schema

100 of 111 branches covered (90.09%)

Branch coverage included in aggregate %.

7 of 8 new or added lines in 5 files covered. (87.5%)

13 existing lines in 2 files now uncovered.

405 of 473 relevant lines covered (85.62%)

8.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.0
/src/controller/staff/modifyStaffByIdController.ts
1
import { Request, Response } from 'express';
2
import mongoose from 'mongoose';
3
import iStaff from '../../models/staff/staffInterface.js';
4
import { modifyStaffById } from '../../services/staff/modifyStaffById.js';
5

6
export async function modifyStaffByIdController(
7
  req: Request<{ id: string }, {}, Partial<iStaff>>,
8
  res: Response
9
) {
10
  try {
4✔
11
    const { id } = req.params;
4✔
12

13
    if (!mongoose.Types.ObjectId.isValid(id)) {
4✔
14
      return res.status(400).json({ error: 'Invalid ID format' });
×
15
    }
16

17
    const result = await modifyStaffById(id, req.body);
4✔
18

19
    if (!result) {
2✔
20
      return res.status(404).json({ error: 'Staff member not found' });
1✔
21
    }
22

23
    return res.status(200).json(result);
1✔
24

25
  } catch (error: unknown) {
26
    if (error instanceof mongoose.Error.ValidationError) {
2✔
27
      return res.status(400).json({ error: error.message });
1✔
28
    }
29

30
    if (error instanceof mongoose.Error.CastError) {
1✔
NEW
31
      return res.status(400).json({ error: error.message });
×
32
    }
33

34
    if (error instanceof Error) {
1✔
35
      return res.status(500).json({ error: error.message });
1✔
36
    }
37

38
    return res.status(500).json({ error: 'Internal Server Error' });
×
39
  }
40
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc