MCPcopy Index your code
hub / github.com/nodejs/node / auditError

Function auditError

deps/npm/lib/utils/audit-error.js:8–38  ·  view source on GitHub ↗
(npm, report)

Source from the content-addressed store, hash-verified

6// Returns 'true' if there was an error, false otherwise.
7
8const auditError = (npm, report) => {
9 if (!report?.error) {
10 return false
11 }
12
13 if (npm.command !== 'audit') {
14 return true
15 }
16
17 const { error } = report
18
19 // ok, we care about it, then
20 log.warn('audit', error.message)
21 const { body: errBody } = error
22 const body = Buffer.isBuffer(errBody) ? errBody.toString() : errBody
23 if (npm.flatOptions.json) {
24 output.buffer({
25 message: error.message,
26 method: error.method,
27 uri: replaceInfo(error.uri),
28 headers: error.headers,
29 statusCode: error.statusCode,
30 body,
31 })
32 } else {
33 output.standard(body)
34 }
35
36 // XXX we should throw a real error here
37 throw 'audit endpoint returned an error'
38}
39
40module.exports = auditError

Callers 2

reifyOutputFunction · 0.70
auditAdvisoriesMethod · 0.50

Calls 3

warnMethod · 0.80
toStringMethod · 0.45
bufferMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…