5
5
* @description
6
6
* Process "error" docType docs and generate errorNamespace docs
7
7
*/
8
- module . exports = function errorDocsProcessor ( errorNamespaceMap , getMinerrInfo ) {
8
+ module . exports = function errorDocsProcessor ( log , errorNamespaceMap , getMinerrInfo ) {
9
9
return {
10
10
$runAfter : [ 'tags-extracted' ] ,
11
11
$runBefore : [ 'extra-docs-added' ] ,
12
12
$process : function ( docs ) {
13
13
14
+ // Get the extracted min errors to compare with the error docs, and report any mismatch
15
+ var collectedErrors = require ( '../../../build/errors.json' ) . errors ;
16
+ var flatErrors = [ ] ;
17
+
18
+ for ( var namespace in collectedErrors ) {
19
+ for ( var error in collectedErrors [ namespace ] ) {
20
+ flatErrors . push ( namespace + ':' + error ) ;
21
+ }
22
+ }
23
+
14
24
// Create error namespace docs and attach error docs to each
15
25
docs . forEach ( function ( doc ) {
16
26
var parts , namespaceDoc ;
17
27
18
28
if ( doc . docType === 'error' ) {
19
29
30
+ var matchingMinErr = flatErrors . indexOf ( doc . name ) ;
31
+
32
+ if ( matchingMinErr === - 1 ) {
33
+ log . warn ( 'Error doc: ' + doc . name + ' has no matching min error' ) ;
34
+ } else {
35
+ flatErrors . splice ( matchingMinErr , 1 ) ;
36
+ }
37
+
20
38
// Parse out the error info from the id
21
39
parts = doc . name . split ( ':' ) ;
22
40
doc . namespace = parts [ 0 ] ;
@@ -41,6 +59,10 @@ module.exports = function errorDocsProcessor(errorNamespaceMap, getMinerrInfo) {
41
59
}
42
60
} ) ;
43
61
62
+ flatErrors . forEach ( function ( value ) {
63
+ log . warn ( 'No error doc exists for min error: ' + value ) ;
64
+ } ) ;
65
+
44
66
errorNamespaceMap . forEach ( function ( errorNamespace ) {
45
67
docs . push ( errorNamespace ) ;
46
68
} ) ;
0 commit comments