MCPcopy Index your code
hub / github.com/nodeSolidServer/node-solid-server / HTTPError

Function HTTPError

lib/http-error.mjs:3–33  ·  view source on GitHub ↗
(status, message)

Source from the content-addressed store, hash-verified

1import { inherits } from 'util'
2
3export default function HTTPError (status, message) {
4 if (!(this instanceof HTTPError)) {
5 return new HTTPError(status, message)
6 }
7
8 // Error.captureStackTrace(this, this.constructor)
9 this.name = this.constructor.name
10
11 // If status is an object it will be of the form:
12 // {status: , message: }
13 if (typeof status === 'number') {
14 this.message = message || 'Error occurred'
15 this.status = status
16 } else {
17 const err = status
18 let _status
19 let _code
20 let _message
21 if (err && err.status) {
22 _status = err.status
23 }
24 if (err && err.code) {
25 _code = err.code
26 }
27 if (err && err.message) {
28 _message = err.message
29 }
30 this.message = message || _message
31 this.status = _status || _code === 'ENOENT' ? 404 : 500
32 }
33}
34
35inherits(HTTPError, Error)

Callers 9

linksHandlerFunction · 0.85
canMethod · 0.85
copyFunction · 0.85
handlerFunction · 0.85
globHandlerFunction · 0.85
handlerFunction · 0.85
handlerFunction · 0.85
multiFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected