保誠-保戶業務員媒合平台
Tomas
2022-05-19 957a1f10a06fdbb76f1a0ba94fe44126c613fee3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict'
 
const extractError = require('./extractWebpackError')
 
/**
 * Applies all transformers to all errors and returns "annotated"
 * errors.
 *
 * Each transformer should have the following signature WebpackError => AnnotatedError
 *
 * A WebpackError has the following fields:
 * - message
 * - file
 * - origin
 * - name
 * - severity
 * - webpackError (original error)
 *
 * An AnnotatedError should be an extension (Object.assign) of the WebpackError
 * and add whatever information is convenient for formatting.
 * In particular, they should have a 'priority' field.
 *
 * The plugin will only display errors having maximum priority at the same time.
 *
 * If they don't have a 'type' field, the will be handled by the default formatter.
 */
function processErrors (errors, transformers) {
  const transform = (error, transformer) => transformer(error)
  const applyTransformations = (error) => transformers.reduce(transform, error)
 
  return errors.map(extractError).map(applyTransformations)
}
 
module.exports = processErrors