@@ -26,8 +26,8 @@ const { deleteFile } = require('../files');
2626const { getChangefiles } = require ( '../unpaywall/api' ) ;
2727const { updateReportMail } = require ( '../mail' ) ;
2828
29- async function endJobAsError ( ) {
30- await fail ( ) ;
29+ async function endJobAsError ( err ) {
30+ await fail ( err ) ;
3131 const state = getState ( ) ;
3232 await createReport ( state ) ;
3333 updateReportMail ( state ) ;
@@ -64,7 +64,7 @@ async function downloadSnapshotProcess() {
6464 filename = await downloadSnapshot ( ) ;
6565 } catch ( err ) {
6666 appLogger . error ( '[job][snapshot][download]: Cannot download snapshot' ) ;
67- await endJobAsError ( ) ;
67+ await endJobAsError ( err ) ;
6868 appLogger . error ( '[job][snapshot][download]: download snapshot job is finished with an error' , err ) ;
6969 return ;
7070 }
@@ -101,7 +101,7 @@ async function downloadInsertSnapshotProcess(jobConfig) {
101101 filename = await downloadSnapshot ( ) ;
102102 } catch ( err ) {
103103 appLogger . error ( '[job][snapshot][download][insert]: Cannot download snapshot' ) ;
104- await endJobAsError ( ) ;
104+ await endJobAsError ( err ) ;
105105 appLogger . error ( '[job][snapshot][download][insert]: Download insert snapshot job is finished with an error' , err ) ;
106106 return ;
107107 }
@@ -114,7 +114,7 @@ async function downloadInsertSnapshotProcess(jobConfig) {
114114 await insertDataUnpaywall ( jobConfig ) ;
115115 } catch ( err ) {
116116 appLogger . error ( `[job][snapshot][download][insert]: Cannot insert the content of snapshot [${ jobConfig . filename } ]` ) ;
117- await endJobAsError ( ) ;
117+ await endJobAsError ( err ) ;
118118 appLogger . error ( '[job][snapshot][download][insert]: Download insert snapshot job is finished with an error' , err ) ;
119119 return ;
120120 }
@@ -170,7 +170,7 @@ async function downloadInsertChangefilesProcess(jobConfig) {
170170 changefilesInfo = await getChangefiles ( interval , startDate , endDate ) ;
171171 } catch ( err ) {
172172 appLogger . error ( '[job][changefiles][download][insert]: Cannot get changefiles' , err ) ;
173- await endJobAsError ( ) ;
173+ await endJobAsError ( err ) ;
174174 appLogger . error ( '[job][changefiles][download][insert]: Download and insert changefile job is finish with an error' , err ) ;
175175 return ;
176176 }
@@ -191,7 +191,7 @@ async function downloadInsertChangefilesProcess(jobConfig) {
191191 await downloadChangefile ( changefilesInfo [ i ] , interval ) ;
192192 } catch ( err ) {
193193 appLogger . error ( `[job][changefiles][download][insert]: Cannot download changefile [${ changefilesInfo [ i ] . filename } ]` ) ;
194- await endJobAsError ( ) ;
194+ await endJobAsError ( err ) ;
195195 appLogger . error ( '[job][changefiles][download][insert]: Download and insert changefile job is finish with an error' , err ) ;
196196 return ;
197197 }
@@ -202,7 +202,7 @@ async function downloadInsertChangefilesProcess(jobConfig) {
202202 await insertDataUnpaywall ( jobConfig ) ;
203203 } catch ( err ) {
204204 appLogger . error ( `[job][changefiles][download][insert]: Cannot insert changefile [${ changefilesInfo [ i ] . filename } ]` ) ;
205- await endJobAsError ( ) ;
205+ await endJobAsError ( err ) ;
206206 appLogger . error ( '[job][changefiles][download][insert]: Download and insert changefile job is finish with an error' , err ) ;
207207 return ;
208208 }
@@ -248,7 +248,7 @@ async function insertFileProcess(jobConfig) {
248248 await insertDataUnpaywall ( jobConfig ) ;
249249 } catch ( err ) {
250250 appLogger . error ( `[job][${ type } ][insert]: Cannot insert ${ type } [${ jobConfig . filename } ]` ) ;
251- await endJobAsError ( ) ;
251+ await endJobAsError ( err ) ;
252252 appLogger . error ( `[job][${ type } ][insert]: Insert changefile job is finish with an error` , err ) ;
253253 return ;
254254 }
0 commit comments