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

titarenko / buhoi / 11380239875

17 Oct 2024 07:21AM UTC coverage: 83.043% (+0.4%) from 82.618%
11380239875

push

github

web-flow
Merge pull request #53 from lafayette/github-actions

switch to github actions, fix some tests

121 of 206 branches covered (58.74%)

382 of 460 relevant lines covered (83.04%)

3.33 hits per line

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

84.21
/src/web-server/middleware/error-handler.js
1
const log = require('totlog')(__filename)
1✔
2
const assert = require('assert')
1✔
3

4
module.exports = function errorHandler ({
1!
5
  ValidationError,
6
  NotAuthenticatedError,
7
  NotAuthorizedError,
8
  NotFoundError,
9
  ProcedureTimeoutError,
10
} = { }) {
11
  assert(Error.isPrototypeOf(ValidationError))
1✔
12
  assert(Error.isPrototypeOf(NotAuthenticatedError))
1✔
13
  assert(Error.isPrototypeOf(NotAuthorizedError))
1✔
14
  assert(Error.isPrototypeOf(NotFoundError))
1✔
15
  assert(Error.isPrototypeOf(ProcedureTimeoutError))
1✔
16

17
  return function errorHandlerMiddleware (error, req, res, next) {
1✔
18
    switch (true) {
6!
19
      case error instanceof ValidationError: return res.status(400).json(error)
1✔
20
      case error instanceof NotAuthenticatedError: return res.status(401).end()
1✔
21
      case error instanceof NotAuthorizedError: return res.status(403).end()
×
22
      case error instanceof NotFoundError: return res.status(404).end()
1✔
23
      case error instanceof ProcedureTimeoutError: return res.status(408).end()
×
24
      default: {
25
        if (error && error.type === 'request.aborted') {
3!
26
          return res.status(400).end()
×
27
        }
28
        log.error('%s %s (session %s) failed due to', req.method, req.path, req.session, error)
3✔
29
        return res.status(500).end()
3✔
30
      }
31
    }
32
  }
33
}
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

© 2025 Coveralls, Inc