File tree 5 files changed +21
-40
lines changed 5 files changed +21
-40
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
const constants = require ( './constants' ) ;
2
- const errors = require ( './errors' ) ;
3
2
4
3
module . exports = class definitions {
5
4
constructor ( ) {
6
5
this . constants = constants ;
7
- this . errors = errors ;
8
6
}
9
7
} ;
Original file line number Diff line number Diff line change
1
+ exports . PreProcessError = class PreProcessError extends Error {
2
+ constructor ( ...args ) {
3
+ super ( ...args ) ;
4
+ this . code = 'ERR_PREPROCESS' ;
5
+ this . name = 'PreProcessError' ;
6
+ this . stack = `${ this . message } \n${ new Error ( ) . stack } ` ;
7
+ }
8
+ } ;
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ const path = require('path');
4
4
const { promisify } = require ( 'util' ) ;
5
5
const cson = require ( 'cson' ) ;
6
6
const { checksum } = require ( './utils' ) ;
7
+ const { PreProcessError } = require ( './errors' ) ;
7
8
8
9
const readFile = promisify ( fs . readFile ) ;
9
10
const getStat = promisify ( fs . stat ) ;
@@ -13,9 +14,8 @@ class PreProcessor {
13
14
this . container = container ;
14
15
this . logger = logger ;
15
16
this . platform = process . platform ;
16
- const { constants, errors } = this . container . module ( 'definitions' ) ;
17
+ const { constants } = this . container . module ( 'definitions' ) ;
17
18
this . constants = constants ;
18
- this . errors = errors ;
19
19
}
20
20
21
21
async processChangeSet ( event , changedFile ) {
@@ -65,10 +65,13 @@ class PreProcessor {
65
65
} ;
66
66
} catch ( err ) {
67
67
// if err.code === 'ENOENT', it means that the 'changedFile' has been removed
68
- return {
69
- event : this . constants . events . FILE_DELETE ,
70
- file : changedFile
71
- } ;
68
+ if ( err . code === 'ENOENT' ) {
69
+ return {
70
+ event : this . constants . events . FILE_DELETE ,
71
+ file : changedFile
72
+ } ;
73
+ }
74
+ throw new PreProcessError ( `Error occurred while preprocessing event: ${ err . message } ` ) ;
72
75
}
73
76
}
74
77
}
Original file line number Diff line number Diff line change @@ -21,9 +21,8 @@ module.exports = class Sync {
21
21
this . lock = new Lock ( ) ;
22
22
this . preprocessor = this . container . module ( 'preprocessor' ) ;
23
23
this . github = this . container . module ( 'github' ) ;
24
- const { constants, errors } = this . container . module ( 'definitions' ) ;
24
+ const { constants } = this . container . module ( 'definitions' ) ;
25
25
this . constants = constants ;
26
- this . errors = errors ;
27
26
}
28
27
29
28
/**
@@ -65,6 +64,9 @@ module.exports = class Sync {
65
64
this . queue . enqueue ( syncEvent ) ;
66
65
this . logger . info ( `[Queue] ${ this . queue . length ( ) } items in sync queue!` ) ;
67
66
this . triggerSync ( ) ;
67
+ } )
68
+ . catch ( ( err ) => {
69
+ this . logger . error ( 'Preprocess failed' , err ) ;
68
70
} ) ;
69
71
}
70
72
You can’t perform that action at this time.
0 commit comments